Jump to content

[Plugin] [ODFC] On Demand Fuel Cells (v1.0 / KSP 0.90)


Orum

Recommended Posts

Fresh out of the box from Okram Industries, I bring you "On Demand Fuel Cells." What is a fuel cell? I'm glad you asked. Put simply, it burns fuel to produce ElectricCharge, similar to what was used in the Apollo program. What fuel? Well, that depends on what mode you have it in. As for the "On Demand" part, the idea is to only burn fuel when you really need to, and otherwise not do anything.

To clarify, this is actually a two-part mod. On the surface there are the included parts you can play around with right now, and are usable in stock KSP with no other dependencies. They come in both radial and stackable form, and each features three sizes that I hope will cover almost all your needs for stock KSP. I've tried my best to balance these, but as there is no concept of a "fuel cell" in stock, it's a bit of a guess. I'll happily take any comments or criticism on these, from aesthetics to balance.

Underneath, however, lies a powerful plugin that I've tried to make as flexible as possible to allow support for use with other mods and other users' creations. It features support for things not used in the stock parts, like byproducts for use with something like [thread=40667]TACLS[/thread]. A significant effort has gone into documenting the plugin as well as its implications to consider when modeling parts. This documentation is included in the distributed archive.

Download v1.0:

KerbalStuff | Dropbox

Also available via [thread=100067]CKAN[/thread] - Last tested on KSP 0.90

Javascript is disabled. View full album

FAQ: (This is included in the archive but is posted here for ease of access.)

Q: Why is it not generating power?

A: Check to see what the "Status" says in the tweakable (right-click) menu. "Nominal" means it is generating power. If it says "No Demand", see the next question. The other states are fairly self-explanatory.

Q: Why does it the "Status" say "No Demand" when my ElectricCharge is less than 100% full?

A: The fuel cells are meant to only provide power when it is needed, i.e. "on demand." As vessels often have several means of generating power, such as solar panels, RTGs, or engines with alternators, it is best to let the ElectricCharge (EC) stored in batteries (or any other part of the vessel) "float" up and down with supply and demand. Only when there is still demand for power, without additional supply to compensate, will the fuel cell burn precious fuel to produce the required EC. The "Threshold" tweakable can be used to decide at what point the fuel cell should generate power, in percent of total vessel EC.

Q: Should I ever raise the "Threshold" setting?

A: In most cases, no, and this is why the default value is the minimum. It's best to leave this setting as low as possible to make the best use of a vessel's limited resources. There are, however, a couple cases where it may be beneficial to raise this value, permanently or temporarily.

The first case is when you have several fuel cells on a single vessel, operating in different modes (if they are in the same mode you want identical threshold settings). You may want one fuel type used over another, e.g. (with the included parts) LiquidFuel + Oxidizer to be preferred over MonoPropellant. The simplest way to do this is just to raise the threshold of the fuel cell burning the preferred fuel by one increment above the other. Then, only if the power demands rise above what the higher threshold fuel cell can provide, and sink below what the secondary fuel cell's threshold is, will it start burning the more precious or desirable fuel to make up for the difference.

The second case is if you are separating a single vessel into multiple vessels, via a decoupler, separator, or docking port, and one of the parts will be limited in its ability to produce ElectricCharge. For example, imagine a battery-powered Lunar Excursion Module (LEM) separating from a Command/Service Module (CSM) that holds the fuel cell(s) but only a fraction of the total EC. You would want the LEM to be fully charged before separating, so you can get the maximum charge out of its batteries for landing on the Mun. Here you would want to temporarily set the threshold to 100%, just before you plan to separate the LEM. As soon as things are fully charged, set the threshold back down and separate the LEM, and continue your Mun landing with full power.

Q: I've set the "Threshold" to 100%, and despite having enough power from other sources, it keeps burning fuel! Why?

A: I'll avoid a full technical description of why this happens, but suffice it to say it's due to a limitation within the Unity engine. For this reason I strongly recommend never leaving any fuel cell "Threshold" at 100% for anything more than a brief instant, or you may be wasting fuel. It's also theoretically possible, though less likely, for this to occur at even lower percentages, in cases where you have large power draws (e.g. several ion thrusters), large alternative sources of power (e.g. big solar panels in full sun near Kerbol), and very little maximum ElectricCharge for a craft (no batteries).

The only case where setting the "Threshold" tweakable to 100% will not waste fuel is when there are no alternative sources of power (remember, some engines generate power) for this stage or any later stage containing the fuel cell, and there will be no docking with the vessel ever.

License:

Note that there are actually two separate licenses in use here. The plugin itself and its source code (which is included in the archive) are licensed under the CC BY-NC-SA-4.0, a copy of which is included in the archive. Everything else in the archive (except the CC BY-NC-SA license itself) is licensed under my own license which is also included in the archive, and reproduced here:

All files contained within, with the exception of the CC BY-NC-SA-4.0 license itself, are copyright Orum on the KSP forums (

http://forum.kerbalspaceprogram.com/members/100536-Orum).

The plugin (ODFC.dll) and its source code (files contained within the PluginSrc directory of this archive) are licensed under the CC BY-NC-SA-4.0 license. The CC BY-NC-SA-4.0 license is included in the "CC BY-NC-SA-4.0.txt" file, and can also be found at this URL: https://creativecommons.org/licenses/by-nc-sa/4.0/legalcode

1. Definitions:

a. Content - Copyrighted materials not licensed under the CC BY-NC-SA-4.0 license or consisting of the CC BY-NC-SA-4.0 license itself.

b. Component - Any portion of the content defined above.

c. Hosting - Keeping a copy, ephemeral or permanent, of the content on a system with the intent to distribute.

d. Non-Commercial Use - Use of the content where every party and every potential party is not required to pay a fee or provide compensation, beyond Internet access fees, in order to access said content at every quality level available to any party other than the party responsible for creating or hosting the content.

e. Commercial Use - Use of the content that does not fall under the definition of "non-commercial" above.

f. Content Management System - A system intended to facilitate users with the installation (including downloading) of or the management of (including installation and uninstallation) the content or components thereof.

g. Repackaging - Combining a component bundled in a manner that precludes separation of the content prior to the downloading, extraction, or installation of the component by anyone other than the end-user of the content; or the download, extraction, or installation of a component where the component does not consist of the entire content by anyone other than the end-user of the content.

h. I/me - The owner of the copyright.

i. You - The individual or organization exercising the rights granted or restricted by this license.

j. Third Party - Any party that is not you or me.

k. Party - Any individual or organization.

2. Permission is explicitly granted for the following, but does not imply permission for items similar to the following:

a. Hosting and distribution of content by sites to which I have uploaded the content. This is limited to KerbalStuff (kerbalstuff.com) and Dropbox (dropbox.com).

b. Downloading, installing, uninstalling, or other management of the content via "The Comprehensive Kerbal Archive Network" (CKAN; https://github.com/KSP-CKAN/CKAN), and other non-commercial content management systems, provided they don't violate any other portion of this license.

c. Non-commercial use of the content or components.

d. Creation, distribution, or use of files created by you or a third party modifying the included *.cfg (config) files via ModuleManager (https://github.com/sarbian/ModuleManager), provided they don't violate any other portion of this license.

e. Creation, distribution, or use of textures created by you or a third party for use with included components, provided they don't violate any other portion of this license.

3. Additionally, explicitly forbidden is the following:

a. Repackaging of the content by anyone other than me without explicit permission or authorship from me.

b. Asserting or implying that endorsement or sponsorship has been granted to you or anything created, edited, or otherwise modified by you without explicit claims made by me.

c. Commercial use of the content or components.

d. False claims of ownership of the content or the copyright of the content.

4. This license, or an updated version of it authored by me, must be included in an unmodified state with the content or components thereof.

As this is the first public release there is no changelog. Future releases will include it.

Acknowledgements: stupid_chris for debugging assistance and RealChute, RoverDude and PorkJet and taniwha and others (can't remember them all) for help with Blender, Mu for buggy PartTools and not being there while being there and his pro-modder t-shirt, darklight for being upside down and for moral support and his exception detector, SirCmpwn for hosting KerbalStuff, the folks over at CKAN for making a good mod manager, and last but not least all of #kspmodders (except SpaceCore) for their assistance and tolerating me. Without them, this would not have been possible!

Edited by Orum
Fixing Typo
Link to comment
Share on other sites

The art style is certainly interesting. Universal Storage also has a fuel cell if you're looking for balance comparisons.

Underneath, however, lies a powerful plugin that I've tried to make as flexible as possible to allow support for use with other mods and other users' creations. It features support for things not used in the stock parts, like byproducts for use with something like [thread=40667]TACLS[/thread]. A significant effort has gone into documenting the plugin as well as its implications to consider when modeling parts. This documentation is included in the distributed archive.

I read the DocsForModders, and while it documents the API methods and parameters, it's missing a "big picture" description - why would I use ODFC.dll in my mod? Is it only to create other fuel cell parts, or is it a general resource conversion library, like Regolith? What are the advantages/disadvantages of ODFC vs Regolith?

Link to comment
Share on other sites

Is it only to create other fuel cell parts, or is it a general resource conversion library, like Regolith? What are the advantages/disadvantages of ODFC vs Regolith?

It's only for fuel cells. The reason is it's designed around using ElectricCharge to calculate when fuel needs to be burned, so it won't serve the purpose of general conversion well. That said, it would be trivial to add support for using something other than EC as the primary output/determining factor for when fuels are consumed and byproducts are produced. So, if you want that, let me know and I'll add it.

As for a comparison with Regolith, I can't help you as I'm not really sure. I've never used it in one of my games and haven't looked at the plugin. But, if there's something it does that you'd like ODFC to do, just ask. I'm always open to suggestions.

Life Support scrubers going off when low EC whould be nice, green houses too ;)

Not sure if there's a way to do something like this and still make it a generic (i.e. config file based) thing. It's probably something that's better done in the life support mod.

Edited by Orum
Link to comment
Share on other sites

In CKAN it conflics with another mod:

Oh no! We tried to overwrite a file owned by another mod!

Please try a `ckan update` and try again.

If this problem re-occurs, then it maybe a packaging bug.

Please report it at:

https://github.com/KSP-CKAN/CKAN-meta/issues/new

Please including the following information in your report:

File : GameData/Okram/Agencies/Okram.cfg

Installing Mod : ODFC 1.0

Owning Mod : SatBatts

CKAN Version : development (beta)

Your GameData has been returned to its original state.

Error!

Link to comment
Share on other sites

In CKAN it conflics with another mod:

I'm aware of this (it conflicting with my own mods). However, I don't know if there's really a way to fix this. Let me explain.

CKAN does not let you share ownership of a file between multiple mods. As this is by design I do not believe it will change. This presents an issue for modders who want to share identical content (agencies, flags) between multiple mods they are the author of--each file can only be owned by one mod. The obvious solution here is to make a mod with the shared content (in my case, just the flags/agency), and have both other mods depend on that shared mod.

The problem then becomes hosting of this mod. I asked SirCmpwn (developer/administrator of KerbalStuff) on IRC if it was okay to have such a mod on KerbalStuff, as I know in the past he has deleted mods consisting of just flags. His opinion on the matter was that such a dependency should not be hosted on KerbalStuff, and that CKAN should instead support files being owned by multiple mods. You can see the issue this causes.

I'm looking to see if I can't find another way around the problem, such as hosting the shared content on DropBox, but I haven't been able to get this to work yet via CKAN. The alternative is to create a GitHub project just for the flag/agency, but I fear that may be deleted for the same reason SirCmpwn doesn't want such content on KerbalStuff.

Link to comment
Share on other sites

Alright, I'm putting the shared assets on github today, and I hope to have pull requests submitted for the netkan files this evening.

You will probably need to remove either ODFC or SatBatts (whichever you have reinstalled) and re-add them after the pull requests are approved. Sorry for any inconvenience. :0.0:

Edit: Pull request has been merged, try uninstalling whichever mod of mine you have installed and reinstalling both of them, and it should work now (in theory).

Edited by Orum
Link to comment
Share on other sites

  • 1 month later...

Nice mod that deserves more attention!

- - - Updated - - -

Could this, please, gain a Hydrogen+Oxygen mode like the Universal Storage fuel cell? This one is otherwise very useful.

Indeed, I highly advice the creation of a MM script that would alter Universal Storage fuel cell to automaticly store and generate power when needed. This would be it's primary application!

Link to comment
Share on other sites

  • 4 weeks later...

Sorry for the late replies, and for not yet updating it to work with KSP 1.0 (not even sure if any changes are needed). Between a patio removal/rebuild and a kitchen remodel, I've been extremely busy, and I don't expect to be able to devote much time to gaming or development until the end of the month.

Out of curiosity, how much fuel do you expend for how much electric charge?

When you mouse-over the parts in the editor and view the detailed part info (right-click), it lists all rates, both for "MaxEC" (the maximum electric charge it will generate per second), and below that it lists all fuels required per-second when generating at the maximum rate. At less than the maximum, fuel rates are scaled linearly--e.g. generating electricity at 50% of the MaxEC, it will use 50% of all fuels listed at that rate.

Could this, please, gain a Hydrogen+Oxygen mode like the Universal Storage fuel cell? This one is otherwise very useful.

Sure, anyone is more than welcome to write a MM script to do this. I'd also recommend you create "Water" as a byproduct if the resource is available, but it's up to you. NihilRex was going to write some, but I'm not sure if he ever got around to it, and I haven't been on IRC recently to talk to him. However, if you write MM configs, are willing to share them, and would like me to list them in the first post, I'd be happy to. Just post a message in this thread and I'll link people directly to your post with the configs. All I ask is that you list the version of ODFC (probably KSP too, and maybe even MM version) that you used when you wrote the config, and include that in the post. Then any updates can be done just by editing your post.

Is there away to get it work in the background, If your not active vessel it's not using any Resources ?

Probably. I haven't tried yet, but I'll put it on my "TODO" list once any necessary updates to get things working with KSP 1.0 are done.

Edited by Orum
Link to comment
Share on other sites

  • 1 month later...

pretty sure* its in stock now (fuel cells only produce energy if batteries not full and not enough solar panels). so what does this mod do for me?

*haven't tested without mods yet but as far as i know none of my installed mods change fuel cells behaviour

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...