Jump to content

Experimenting with resource conversion ... passing the info along!


Recommended Posts

My first contribution to this fine Community -- and I can assure you it won't be my last. :D Hopefully this points anyone who needs the information in the right direction.

I've been monkeying (Chaka!) around with adding CO2 Scrubbers and whatnot to Pods and Station Modules. Following the brilliant examples in TACLifeSupport http://forum.kerbalspaceprogram.com/index.php?/topic/37449-102-tac-life-support-v011120-5apr/ by TaranisElsu, I attempted to add the relevant modules from that pack into Pods and Station Modules that I was directly using, but it didn't quite work out the way I wanted. I was calling the parts instead of the functions; that's where I was going wrong.

Turns out we can simply add these things directly into each .cfg file, and not have them be static (because one Pod for two Kerbals should not have the same Scrubber as a Pod meant for six!). We can tweak how "efficient" these parts are, as well as how "converty" they are, according to the Pod or Module.

All credit for the code you're about to see below goes to TaranisElsu and TacLifeSupport. I'm just a bit of a hack who tweaked the numbers for simplification, and I'm sure TaranisElsu will yell at me for it. ;)

In each part file you want a Convertor/Scrubber/Recycler in, you can add this to the config, and you may have more than one convertor! Simply make a new MODULE {} entry for it.

// Watch this ... don't need separate config files, do it right here in the .cfg file! Needs TacLifeSupport.
    MODULE
    {
        name = TacGenericConverter
        converterName = CO2 Scrubber

        // A scaling factor by which the resource amounts are multiplied -- change the last number for however many Kerbals the part is rated for (this one is for 4 Kerbals)
        conversionRate = 0.04

        // A comma separated list of resources to use as inputs.
        // For each resource, list the resource name and the amount (which
        // is multiplied by the conversionRate)
        inputResources = CarbonDioxide, 0.1, ElectricCharge, 0.4

        // A comma separated list of resources to output. Same as above
        // but also specify whether it should keep converting if the
        // resource is full (generating excess that will be thrown away).
        outputResources = Oxygen, 0.025, false, Waste, 0.075, true
    }

As you can see in the code, the above unit is rated for 4 Kerbals, and has an efficiency rating of ~25%. Every 0.1 units of CO2, plus 0.4 ElectricCharge will output 0.025 units of Oxygen and the remaining 0.075 units (in this setup) is Waste. The inputResources and outputResources can be anything we need; but it's good to keep things realistic. No reason to have this thing generating MonoPropellant, ElectricCharge and LiquidFuel/Oxidizer, although it could.

And remember that anything outputResource generated is stored automatically if that resource storage is specified on-board. For example, if we're storing Waste on board, the excess ("Waste") will go into the Waste resource pool, because that resource was specified as being on board. "Waste" literally can mean anything. Anything. 

Treat WasteWater the same way. Outputs are likely CarbonDioxide and Methane (you'll need tanks to store both separately), then use the CO2 Scrubber to get Oxygen from it.

If we really wanted to get creative, we can use a Sabatier Process to turn Carbon and Methane into nearly anything. :)

Hope this is helpful. Again, all credits go to TaranisElsu and TacLifeSupport for the code.

Edited by BetaguyGZT
stupid code entry ... rasm frasm ...
Link to comment
Share on other sites

Even more experimentation. Use these as your needs require, tweak them for proper realism and scaling. :) Remember that all code is either TaranisElsu's or a derivative work, and exists in this thread by his/her good graces. Anything I've added to it or come up with on my own that is derivative of TaranisElsu's work is the same licence as TacLifeSupport (CC-BY-NC-SA 3.0).

All Modules require TacLifeSupport (and won't work without it), found here: http://forum.kerbalspaceprogram.com/index.php?/topic/37449-102-tac-life-support-v011120-5apr/

It's a foregone conclusion you'll need to add whatever RESOURCE you're consuming/producing to your part, if it isn't already present.

Also note that I've had issues getting these modules to work with FSFuelSwitch and InterstellarFuelSwitch, even when the resources are added to the resourcesToIgnore = list. It's flaky sometimes -- so be careful what you're producing. Took me half an hour to figure out why a part wasn't loading ... anyway.

Water Purification Module. Simply add this to whatever you need it put into. (Remove the RESOURCE{} bits as needed, I'm including them as a courtesy.)

RESOURCE
{
	name = Water
	amount = 400
	maxAmount = 400
}

RESOURCE
{
	name = WasteWater
	amount = 0
	maxAmount = 100
}

RESOURCE
{
	name = Waste
	amount = 0
	maxAmount = 100
}

MODULE
{
	name = TacGenericConverter
	converterName = Water Purifier

	// A scaling factor by which the resource amounts are multiplied
	conversionRate = 0.04

	// A comma separated list of resources to use as inputs.
	// For each resource, list the resource name and the amount (which
	// is multiplied by the conversionRate)
	inputResources = WasteWater, 0.02, ElectricCharge, 0.04

	// A comma separated list of resources to output. Same as above
	// but also specify whether it should keep converting if the
	// resource is full (generating excess that will be thrown away).
	outputResources = Water, 0.01, false, Waste, 0.01, true
}

Why are we keeping the Waste? You don't have to. As stated, remove the bits you don't want; but this one relies on WasteWater and Water, so I suggest keeping those two. And what proper space-going vessel doesn't have waste handling? Apollo did. :)

More to come. I've got a few more of my own design, but they're a bit .. unrealistic. I need to do some research first to see if they're "correct". ;)

Enjoy!

 

 

Link to comment
Share on other sites

If you want to make your parts balanced to real life, you can see all of my math, and how I derived it, here: https://docs.google.com/spreadsheets/d/1DkWf210viRSNcV8tvDv30vZ_iACj6GeY1Lf_4JdZYds/edit?usp=sharing . Information about resource conversion starts around line 313.

Also, take a look at ModuleResourceConverter, which is in Stock. See the ISRU parts for examples. My code predates that, and they added some neat functionality there.

Have fun :cool:

Link to comment
Share on other sites

Thank you kindly, I'll check it out. :)

I've run into a bit of a funny problem -- after the modules convert so much of an amount of a resource, they seem to "saturate" and begin to NOT convert anymore. 100-200 units is about the best number I can provide before they simply stop functioning. Is this intended, or is there something in the code I'm supposed to be adding, changing or looking for?

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...