Jump to content

That "module resource converter" thing...


Recommended Posts

I need to add a 2nd output of what the generator will create. Im trying to make a real world fuel cell that uses the proper fuels and outputs the 2 real things. So far Ive come up with this, but its not working. Im only getting the electric charge as output.

[code]
!INPUT_RESOURCE
{
!ResourceName = LiquidFuel
!Ratio = 0.0016875
!FlowMode = STAGE_PRIORITY_FLOW
}
!INPUT_RESOURCE
{
!ResourceName = Oxidizer
!Ratio = 0.0020625
!FlowMode = STAGE_PRIORITY_FLOW
}


INPUT_RESOURCE
{
ResourceName = LqdHydrogen
Ratio = 0.0016875
FlowMode = STAGE_PRIORITY_FLOW
}
INPUT_RESOURCE
{
ResourceName = Oxygen
Ratio = 0.0020625
FlowMode = STAGE_PRIORITY_FLOW
}


%OUTPUT_RESOURCE
{
%ResourceName,0 = Water
%ResourceName,1 = ElectricCharge
%Ratio = 1.5
%DumpExcess = false
}

[/code] Edited by lextacy
Link to comment
Share on other sites

you could shorten your code by using @ instead of !, this would eliminate the need for the second input parameters. A far as your output resource, if you are adding a second one you don't need a prefix symbol. You also need to define what part you are modifing.

[code]
@PART[name of part as it appears in the .cfg]

@INPUT_RESOURCE
{
@ResourceName = LqdHydrogen
@Ratio = 0.0016875
@FlowMode = STAGE_PRIORITY_FLOW
}
@INPUT_RESOURCE
{
@ResourceName = Oxygen
@Ratio = 0.0020625
@FlowMode = STAGE_PRIORITY_FLOW
}


OUTPUT_RESOURCE
{
ResourceName = Water
Ratio = 1.5
DumpExcess = false
}

[/code]

Try that. Edited by Taki117
Link to comment
Share on other sites

Shorten it even further by removing all "@FlowMode" lines. No need to call a modification to them when you're just putting in the same value they already have. Also, Taki, don't forget brackets, or calling the whole module first :P

The %-operator calls "create if it doesn't exist, modify if it does". So it's safe to use almost everywhere, especially if you are worried that another mod might call similar modifications. The only place to avoid it is in the initial PART call.

You can target both stock fuel cell parts with the same MM config.

It's also a good idea to identify the INPUT_RESOURCE nodes you are trying to modify.

Remember that you may potentially want to modify the Ec/s ratio as well, in which case you need to call a modification to the existing OUTPUT_RESOURCE node. I've included one below, add your preferred value or remove the node as you see fit.

Then, because you are producing a new resource, you should provide a small amount of storage for that resource inside your part.

Additionally, for personal tweaks you should specify an AFTER or FINAL pass, so that they definitely load last and overwrite anything else.

Finally, you're referencing non-stock resources, so you should include a dependency on the mod that adds these resources, to avoid your game crashing on loading if the resources are missing for some reason.


[CODE]
@PART[FuelCell,FuellCellArray]:FINAL:NEEDS[CommunityResourcePack]
{
%MODULE[ModuleResourceConverter]
{
%INPUT_RESOURCE[LiquidFuel]
{
%resourceName = LqdHydrogen
%ratio = 0.0016875
}

%INPUT_RESOURCE[Oxidizer]
{
%resourceName = Oxygen
%ratio = 0.0020625
}

%OUTPUT_RESOURCE[ElectricCharge]
{
%ratio = 123456789.0
}

%OUTPUT_RESOURCE
{
%resourceName = Water
%ratio = 1.5
%dumpExcess = false
}
}

%RESOURCE
{
name = Water
amount = 0
maxAmount = 1
}
}[/CODE]



EDIT: note that I cannot test this right now, as I don't have a KSP install handy. Edited by Streetwind
Link to comment
Share on other sites

@Streetwind. That config made it way worse, it went back to liquid fuel and oxidizer. I put back

[SIZE=1][I] INPUT_RESOURCE
{
ResourceName = LqdHydrogen
Ratio = 0.0016875

}
INPUT_RESOURCE
{
ResourceName = Oxygen
Ratio = 0.0020625

}

[/I][SIZE=3]The inputs were showing hydrogen and oxygen the way I had it put. As far as the outputs , thats weird , im stumped[/SIZE][/SIZE]
Link to comment
Share on other sites

I was quietly wondering if something like that would happen, since I had no way to test it. Apparently the NODENAME[target] notation doesn't work in this case, because there is no "name = " field in it, only a field named "resourceName = " which apparently just isn't equivalent :P

In that case, you could probably target them in a different way - maybe with ,0 and ,1 - but since it seems to work for your even untargeted, then you can also leave it like that. It's ambiguous, but ModuleManager seems to be doing it in the right order by default here.

The outputs may not be fully working either because of the attempt to target by resourceName again. Try to remove the "[ElectricCharge]" part there as well. Edited by Streetwind
Link to comment
Share on other sites

AHHHH! HHAHA ... ok I copied paste you code and you mis-capitalized resourceName and ratio....so that killed the inputs....and as far as the outputs, I did this fun thing.

[code]
@PART[FuelCell*]:FINAL
{
!MODULE[ModuleResourceConverter]
{

}

MODULE
{
name = ModuleResourceConverter
ConverterName = Fuel Cell
StartActionName = Start Fuel Cell
StopActionName = Stop Fuel Cell
FillAmount = 0.95
AutoShutdown = false
GeneratesHeat = false
UseSpecialistBonus = false


INPUT_RESOURCE
{
ResourceName = LqdHydrogen
Ratio = 0.0016875
FlowMode = STAGE_PRIORITY_FLOW
}

INPUT_RESOURCE
{
ResourceName = Oxygen
Ratio = 0.0020625
FlowMode = STAGE_PRIORITY_FLOW
}


OUTPUT_RESOURCE
{
ResourceName = ElectricCharge
Ratio = 1.4
DumpExcess = false
}

OUTPUT_RESOURCE
{
ResourceName = Water
Ratio = 1.0
DumpExcess = false
}
}

RESOURCE
{
name = Water
amount = 0
maxAmount = 500
}
}
[/code]

By killing the original module and just re-writing a new converter, I was able to get it to work AND made for a cleaner config with the @%@%@%@% everywhere. Wondering if just using the % water part would have been an alternative?
Link to comment
Share on other sites

[quote name='lextacy']AHHHH! HHAHA ... ok I copied paste you code and you mis-capitalized resourceName and ratio....so that killed the inputs...

*snip*

By killing the original module and just re-writing a new converter, I was able to get it to work AND made for a cleaner config with the @%@%@%@% everywhere.[/QUOTE]

Huh. The field names shouldn't be case sensitive... :confused:

But yeah, the "kill and rewrite" is an option you have. Good to see you got it working! :)
Link to comment
Share on other sites

By the way, a somewhat more robust implementation option: Instead of saying this:

PART[FuelCell*]

you can instead say

PART
[*]:HAS[thing1,thing2,thing3]

where the things in the HAS are filter conditions. This lets you express it in terms of "has ModuleResourceConverter that takes LF and O as inputs and produces electricity as an output." Check the ModuleManager documentation for the syntax details of how to do this.

That way, your .cfg would apply to all parts that [I][U]behave[/U][/I] as a fuel cell, regardless of what they're actually [I][U]named[/U][/I]. Thus, it will continue to work even if Squad adds other fuel-cell type parts in the future, or if someone adds a mod that adds new parts, or whatever.

Here's [URL="http://forum.kerbalspaceprogram.com/threads/139511"]another forum thread[/URL] that contains an example of using ModuleManager in a fashion like this. Edited by Snark
Link to comment
Share on other sites

[quote name='Streetwind']It's not more "robust" as such, it's a different option, depending on what you want. Sometimes you don't want to blanket-change all parts that carry a specific module... but yeah, when you do, search terms are useful.[/QUOTE]

YES! THats why I wildcarded fuel cell, so It would just apply to the 2 squad parts. I need moduleResourceConverter to be open to multiple types because down the road these converters are going to do methane and other various extraction elements.
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...