`Orum

[1.1.2] On Demand Fuel Cells (ODFC v1.1)

Recommended Posts

Original Thread (A new thread for one of my previous mods, for two reasons.  First, I'm splitting the parts and the plugin itself into two separate items in CKAN.  Secondly, it has been so long that I forgot the password to my original account, and I think I used a temporary email to register it.)

ODFC is a plugin to simulate fuel cells in KSP, and do a better job of it than stock's use of a resource converter.  The main difference is it only generates electricity when it's really needed (batteries almost empty), and otherwise lets electricity of a craft float up and down, as it might in a solar powered vehicle when the sun is eclipsed by another celestial body.  It also allows fuel cells to generate byproducts, aimed at supporting life support mods like TACLS.  It also includes a wealth of documentation in order to ease use of the plugin by anyone potentially interested in creating parts that use the plugin, as well as the source code.

For some example parts that demonstrate the plugin, see Okram Industries Fuel Cells (thread, SpaceDock).  Please keep discussion here related to the plugin.

Download on SpaceDock here or DropBox here.  Also available on CKAN.

Change Log:

v1.1
 - Release split into two pieces; plugin is now distributed separately from the OI parts, to ease CKAN support
 - Updated to support KSP v1.1 (KSP 1.0 was not and will not be supported)
 - UI will now hide certain elements if they are not used (mode switching and fuel used is hidden for those with only a single mode; Byproducts is hidden unless there are at least 2 modes, at least one of which has a byproduct)
 - Info screen will now report units in an easier to read and interpret manner (e.g. 0.36/h instead of 0.0001/s)
 - Fixed a bug where floats were truncated to integers when reading the MaxEC value
 - Changed code to use public KSP/Unity functions where applicable
 - Very small code optimizations and organization

v1.0
 - Initial release (for KSP v0.90)

License: CC-BY-NC-SA-4.0

Edited by `Orum
Add change log

Share this post


Link to post
Share on other sites

Intresting mod. Could you make is so that it would be able to generate different kind of output instead of only Electric Charge?

Share this post


Link to post
Share on other sites

I've been thinking about that actually, and it should be relatively easy to make it a generic resource converter.  However, this presents another potential problem, as with generic converters, you often want several outputs.  Take for example the common case of converting ore to liquid fuel and oxidizer, and maintaining the 0.9/1.1 fuel ratio.  While this can be done right now with some trivial modification to the code, which amounts to basically swapping anywhere it uses ElectricCharge to instead using LiquidFuel, and then setting up the appropriate configuration for Oxidizer in the part configuration as a byproduct, this has some potential pitfalls.  What if the user has plenty of liquid fuel, but is nil on Oxidizer?  Then the converter won't trigger.

So I've thought of two potential ways around this.  The crude way is to just have a single 'mode' that checks both resources and if either condition is satisfied, performs the conversion (e.g. in the case of Ore -> LF + OX, with full LF and no OX, it would perform the conversion and the LF converted would just disappear).  But this is again wasteful, so I'm thinking of instead allowing for multiple modes to be active simultaneously, but that trigger independently (i.e. it checks all potential conversions, and runs those that are needed).  This is certainly a bit more complex, because for balance reasons one might want a single mode being active to convert faster than if two different modes were active simultaneously, or maybe only have a byproduct when a specific set of modes are not performed at the same time.  However, I've never been one to shy away from necessary complexity, so yes I'm planning on implementing it.  I still have to hash out the final details, so I can't tell you for sure what will be possible yet.

Sorry for the long winded answer, but here's a...

tl;dr version: Yes.  It will be in the next release that's anything more than just supporting a newer version of KSP.

EDIT: Here's an example of what a new config might look like, if you have any feedback, speak now or forever hold your peace.

EDIT2: Just to clarify the previous example, a preempting conversion will only preempt for the portion of the duty cycle it requires.  E.g., if you can convert 0.5 units of MonoPropellant per second, but only require half of that, the other half of the duty cycle could be spent producing LiquidFuel/Oxidizer.

Edited by `Orum

Share this post


Link to post
Share on other sites

Is there documentation for converting a part to use this system? (want to edit the hydrogen fuel cells from Universal Storage and SETI)

Share this post


Link to post
Share on other sites

Documentation is included in the zip file, it's HTML based and should work in any modern browser.  If you're looking for examples, look at the parts I've made that use this mod; just keep in mind that they're under a different license from this plugin.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now