Jump to content

[1.8.x-1.12.x] Module Manager 4.2.3 (July 03th 2023) - Fireworks season


sarbian

Recommended Posts

Not with the current version. I am considering adding a step that delete value that use a specific naming pattern after all the value and subnode of a node are processed. Something like deleting all var whose name start with an underscore.

Same thing with formula. No way to do 1 line complex math currently. I could do yet an other syntax to handle it but I would need a lib/code to do the parsing.

Note to self :

http://ncalc.codeplex.com/

https://github.com/pieterderycke/Jace

https://github.com/loresoft/Calculator

https://github.com/MathosProject/Mathos-Parser

http://irony.codeplex.com/

Edited by sarbian
Link to comment
Share on other sites

Hi everyone,

I'm trying to do this task with a module manager patch :

For all tanks with LFO :

- Add the firespitter "FSfuelSwitch" module with the given 3 options

- LFO (unchanged)

- LF Only (twice the amount of LF from LFO mode)

- Ox Only (twice the amount of Ox from LFO mode)

- Remove the old resources as they are replaced by firespitter

I was kinda pleased with the following patch (it's not balanced yet and makes all tanks available at start so I could check them fast in game) : http://paste.ubuntu.com/11359289/

In the patched version of the game configuration (I'm looking at the ConfigCache file), I can find my variables in the module instance (you may check this result for the Kerbodyne S3-14400 Tank : http://paste.ubuntu.com/11359383/ )

Is there a way to prevent this "pollution" ?

Is there a way to use formulas in a patch file ?

This patch is not an original idea as it is just a try to make the "Stock Fuel Switch" mod apply to all possible tanks.

While not being able to help with your pollution, just another thing.

I'm currently doing something similar. As LF and O have the same density, LF Only (or Ox Only) doesn't equalize "twice the amount", but rather "both combined".

If a tank has 90 LF / 110 Ox (or whatever, you now the usual ratio :D), it doesn't have 180 LF or 220 Ox, but rather exactly 200 of each in "solo-mode".

Link to comment
Share on other sites

This does't work either. The resource costs in the game are still stock.

What did you name you patch ? It works for me.

EDIT- I named my patch Z_Price.cfg

EDIT- Will run test again to make sure.

Edited by Mecripp2
Link to comment
Share on other sites

I named it DFResourceCosts and put it inside /GameData/Rock/

Change the name the name you have and folder is running before Squad.

EDIT- Would think you can just rename your patch file.

EDIT- Or add :AFTER

@RESOURCE_DEFINITION[LiquidFuel]:AFTER[squad]

{

@unitCost = 10

}

Edited by Mecripp2
Link to comment
Share on other sites

While not being able to help with your pollution, just another thing.

I'm currently doing something similar. As LF and O have the same density, LF Only (or Ox Only) doesn't equalize "twice the amount", but rather "both combined".

If a tank has 90 LF / 110 Ox (or whatever, you now the usual ratio :D), it doesn't have 180 LF or 220 Ox, but rather exactly 200 of each in "solo-mode".

I could guess the volume of a tank from its current then run through all ressources and add all of them with calculations based on density.

I made my own rules for my own setup, it let me have one tank full of LF and an other full of Ox and still have the same ratio.

If you want such complicated calculations you may be interested into Modular Fuel Tanks mod. It does the job for you with all resources.

Not with the current version. I am considering adding a step that delete value that use a specific naming pattern after all the value and subnode of a node are processed. Something like deleting all var whose name start with an underscore.

Same thing with formula. No way to do 1 line complex math currently. I could do yet an other syntax to handle it but I would need a lib/code to do the parsing.

No harm in this, I'm taking all good pratices I can to help not messing up my patches or later have a mod that conflicts with mine.

By the way, is there a way to test a patch just like the test cases I could find on github ? ( I'm an other guy that know nothing of C# :) )

I know the patch task is fast but having to load the entire Unity engine is a pain even with 3/4 of stock parts removed.

I can later provide my tests if you want some non-regression testing.

Link to comment
Share on other sites

You can press ATL F11 on the spacecenter screen and use that menu to reload all the config + patch. Works fine to test patch and you can see the result in the cache.

Link to comment
Share on other sites

Tricky it is. All his resources one must uses.



@CLOUD_LAYER_PACK
{
@CLOUD_LAYER:HAS[@DEFAULTS:HAS[#body[Laythe]]]
{
@DEFAULTS
{
@altitude = 6500
}
}
}

I assume that there is only DEFAULTS node per CLOUD_LAYER node. If not you ll have to replace the


@DEFAULTS
{
@altitude = 6500
}

with


@DEFAULTS,0
{
@altitude = 6500
}

@DEFAULTS,1
{
@altitude = 7500
}

...

Link to comment
Share on other sites

Tricky it is. All his resources one must uses....

You're a superstar!

Am I right in saying i can use | to effect multiple bodies like below?

@CLOUD_LAYER_PACK
{
@CLOUD_LAYER:HAS[@DEFAULTS:HAS[#body[Laythe|Duna|Kerbin]]]
{
@DEFAULTS
{
@altitude = 6500
}
}
}

UPDATE

Think I've answered my own question and the answer is no.

Edited by Paul Kingtiger
Link to comment
Share on other sites

Hello.

I'm trying to modify the stock contracts.cfg file.

Here's an excerpt of one of the stock missions configs:


Base
{
MaximumExistent = 2
TrivialMobileChance = 0
SignificantMobileChance = 10
ExceptionalMobileChance = 30
AllowMobile = True
Expiration
{
MinimumExpireDays = 1
MaximumExpireDays = 7
DeadlineDays = 2982
}
Funds
{
BaseAdvance = 36000
BaseReward = 91000
BaseFailure = 0
MobileMultiplier = 1.5
}
Science
{
BaseReward = 0
MobileMultiplier = 1.25
}
Reputation
{
BaseReward = 21
BaseFailure = 14
MobileMultiplier = 1.5
}
PART_REQUEST
{
Title = Have a research lab at the outpost
Keyword = Scientific
Part = Large_Crewed_Lab
Module = ModuleScienceLab
MinimumScience = 15
Trivial
{
Chance = 20
FundsMultiplier = 1.15
ScienceMultiplier = 1.5
ReputationMultiplier = 1
}
Significant
{
Chance = 30
FundsMultiplier = 1.15
ScienceMultiplier = 1.5
ReputationMultiplier = 1
}
Exceptional
{
Chance = 40
FundsMultiplier = 1.15
ScienceMultiplier = 1.5
ReputationMultiplier = 1
}
}
PART_REQUEST
{
Title = Have a viewing cupola at the outpost
Keyword = Commercial
Part = cupola
Trivial
{
Chance = 20
FundsMultiplier = 1.25
ScienceMultiplier = 1
ReputationMultiplier = 1.25
}
Significant
{
Chance = 30
FundsMultiplier = 1.25
ScienceMultiplier = 1
ReputationMultiplier = 1.25
}
Exceptional
{
Chance = 40
FundsMultiplier = 1.25
ScienceMultiplier = 1
ReputationMultiplier = 1.25
}
}
PART_REQUEST
{
Title = Have an ISRU resource conversion unit at the outpost
Keyword = Commercial
Part = ISRU
Trivial
{
Chance = 5
FundsMultiplier = 1.15
ScienceMultiplier = 1.05
ReputationMultiplier = 1.05
}
Significant
{
Chance = 15
FundsMultiplier = 1.15
ScienceMultiplier = 1.05
ReputationMultiplier = 1.05
}
Exceptional
{
Chance = 25
FundsMultiplier = 1.15
ScienceMultiplier = 1.05
ReputationMultiplier = 1.05
}
}
RESOURCE_REQUEST
{
Name = LiquidFuel
Title = liquid fuel
Keyword = Commercial
Part = fuelTankSmallFlat
ChanceMultiplier = 1
Trivial
{
Amount = 2000
Chance = 5
FundsMultiplier = 1.1
ScienceMultiplier = 1.1
ReputationMultiplier = 1.1
}
Significant
{
Amount = 4000
Chance = 10
FundsMultiplier = 1.2
ScienceMultiplier = 1.2
ReputationMultiplier = 1.2
}
Exceptional
{
Amount = 6000
Chance = 15
FundsMultiplier = 1.3
ScienceMultiplier = 1.3
ReputationMultiplier = 1.3
}
}
RESOURCE_REQUEST
{
Name = Ore
Title = ore
Keyword = Commercial
Module = ModuleResourceHarvester
ChanceMultiplier = 1
Trivial
{
Amount = 1000
Chance = 5
FundsMultiplier = 1.1
ScienceMultiplier = 1.1
ReputationMultiplier = 1.1
}
Significant
{
Amount = 2000
Chance = 10
FundsMultiplier = 1.2
ScienceMultiplier = 1.2
ReputationMultiplier = 1.2
}
Exceptional
{
Amount = 5000
Chance = 15
FundsMultiplier = 1.3
ScienceMultiplier = 1.3
ReputationMultiplier = 1.3
}
}
RESOURCE_REQUEST
{
Name = ElectricCharge
Title = electric charge
Keyword = Scientific
Part = batteryPack
ChanceMultiplier = 1
Trivial
{
Amount = 2500
Chance = 2
FundsMultiplier = 1.05
ScienceMultiplier = 1.05
ReputationMultiplier = 1.05
}
Significant
{
Amount = 5000
Chance = 4
FundsMultiplier = 1.075
ScienceMultiplier = 1.075
ReputationMultiplier = 1.075
}
Exceptional
{
Amount = 7500
Chance = 6
FundsMultiplier = 1.1
ScienceMultiplier = 1.1
ReputationMultiplier = 1.1
}
}
RESOURCE_REQUEST
{
Name = MonoPropellant
Title = monopropellant
Keyword = Commercial
Part = rcsTankMini
ChanceMultiplier = 1
Trivial
{
Amount = 500
Chance = 2
FundsMultiplier = 1.05
ScienceMultiplier = 1.05
ReputationMultiplier = 1.05
}
Significant
{
Amount = 1000
Chance = 4
FundsMultiplier = 1.075
ScienceMultiplier = 1.075
ReputationMultiplier = 1.075
}
Exceptional
{
Amount = 1500
Chance = 6
FundsMultiplier = 1.1
ScienceMultiplier = 1.1
ReputationMultiplier = 1.1
}
}
RESOURCE_REQUEST
{
Name = XenonGas
Title = xenon gas
Keyword = Commercial
Part = xenonTank
ChanceMultiplier = 1
Trivial
{
Amount = 500
Chance = 2
FundsMultiplier = 1.05
ScienceMultiplier = 1.05
ReputationMultiplier = 1.05
}
Significant
{
Amount = 1000
Chance = 4
FundsMultiplier = 1.075
ScienceMultiplier = 1.075
ReputationMultiplier = 1.075
}
Exceptional
{
Amount = 2000
Chance = 6
FundsMultiplier = 1.1
ScienceMultiplier = 1.1
ReputationMultiplier = 1.1
}
}
}

Here's an MM config I wrote for it:


@Base {
@MaximumExistent = 2
@AllowMobile = False
@Expiration
{
MinimumExpireDays = 100
MaximumExpireDays = 400
DeadlineDays = 5000
}
@Funds
{
@BaseAdvance = 7500
@BaseReward = 15000
@BaseFailure = 7500
}
@Science
{
@BaseReward = 15
}
@Reputation
{
@BaseReward = 25
@BaseFailure = 25
}
PART_REQUEST
{
@Title = We need to conduct some long-term research.
@Keyword = Scientific
@Part = Large_Crewed_Lab
@Module = ModuleScienceLab
@MinimumScience = 15
@Trivial
{
@Chance = 2
@FundsMultiplier = 1
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Significant
{
@Chance = 3
@FundsMultiplier = 1.2
@ScienceMultiplier = 1.5
@ReputationMultiplier = 1.5
}
@Exceptional
{
@Chance = 4
@FundsMultiplier = 1.4
@ScienceMultiplier = 1.75
@ReputationMultiplier = 2
}
}
@PART_REQUEST
{
@Title = Please create a living space for resident astronauts.
@Keyword = Commercial
@Part = cupola
@Trivial
{
@Chance = 10
@FundsMultiplier = 1
@ScienceMultiplier = 1
@ReputationMultiplier = 1.25
}
@Significant
{
@Chance = 10
@FundsMultiplier = 1
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Exceptional
{
@Chance = 10
@FundsMultiplier = 1
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
}
@PART_REQUEST
{
@Title = Extract precious Ore to sustain our space program!
@Keyword = Commercial
@Part = ISRU
@Trivial
{
@Chance = 50
@FundsMultiplier = 1.5
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Significant
{
@Chance = 50
@FundsMultiplier = 1.5
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Exceptional
{
@Chance = 50
@FundsMultiplier = 1.5
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
}
@RESOURCE_REQUEST
{
@Title = Converting Ore into Fuel is more efficient in-situ.
@Part = fuelTankX200-8
@ChanceMultiplier = 2
@Trivial
{
@Amount = 360
@Chance = 5
@FundsMultiplier = 1.2
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Significant
{
@Amount = 720
@Chance = 10
@FundsMultiplier = 1.2
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Exceptional
{
@Amount = 1440
@Chance = 15
@FundsMultiplier = 1.2
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
}
@RESOURCE_REQUEST
{
@Title = Please make sure you have enough holding capacity for Ore.
@ChanceMultiplier = 10
@Trivial
{
@Amount = 300
@Chance = 5
@FundsMultiplier = 1.2
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Significant
{
@Amount = 1000
@Chance = 5
@FundsMultiplier = 1.3
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Exceptional
{
@Amount = 1600
@Chance = 5
@FundsMultiplier = 1.4
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
}
@RESOURCE_REQUEST
{
@Title = Extraction, conversion and research consume a lot of electricity.
@Part = z-400battery
@ChanceMultiplier = 5
@Trivial
{
@Amount = 400
@Chance = 2
@FundsMultiplier = 1
@ScienceMultiplier = 1
@ReputationMultiplier = 1
}
@Significant
{
@Amount = 1000
@Chance = 10
@FundsMultiplier = 1.15
@ScienceMultiplier = 1.15
@ReputationMultiplier = 1.15
}
@Exceptional
{
@Amount = 3000
@Chance = 20
@FundsMultiplier = 1.2
@ScienceMultiplier = 1.2
@ReputationMultiplier = 1.2
}
}
@RESOURCE_REQUEST
{
@Title = A monopropellant reserve is always handy.
@Keyword = Commercial
@Part = rcsTankRadial
@ChanceMultiplier = 1
@Trivial
{
@Amount = 60
@Chance = 1
@FundsMultiplier = 1
@ScienceMultiplier = 1
@ReputationMultiplier = 1.05
}
@Significant
{
@Amount = 180
@Chance = 2
FundsMultiplier = 1
ScienceMultiplier = 1
ReputationMultiplier = 1.075
}
@Exceptional
{
@Amount = 360
@Chance = 2
@FundsMultiplier = 1
@ScienceMultiplier = 1
@ReputationMultiplier = 1.1
}
}
@RESOURCE_REQUEST
{
@Name = XenonGas
@Title = Xenon gas is rare and expensive. It can be recovered for a great reward.
@Keyword = Commercial
@Part = xenonTank
@ChanceMultiplier = 1
@Trivial
{
@Amount = 100
@Chance = 2
@FundsMultiplier = 1.05
@ScienceMultiplier = 1.05
@ReputationMultiplier = 1.05
}
@Significant
{
@Amount = 200
@Chance = 2
@FundsMultiplier = 1.1
@ScienceMultiplier = 1.1
@ReputationMultiplier = 1.05
}
@Exceptional
{
@Amount = 500
@Chance = 2
@FundsMultiplier = 1.15
@ScienceMultiplier = 1.1
@ReputationMultiplier = 1.05
}
}
}

I was just wondering... how does the module manager know where to apply the changes? Am I missing something to add next to the RESOURCE_REQUEST, for example?

- - - Updated - - -

HAS only supports and (in the form of , ) not or, sorry.

Who are you replying to?

Link to comment
Share on other sites

I don't mind complex question but that is the basics of MM. Can you please read the fine second post of the thread ? the "Some usefull exemples" is relevant.

Link to comment
Share on other sites

I don't mind complex question but that is the basics of MM. Can you please read the fine second post of the thread ? the "Some usefull exemples" is relevant.

There's nothing about RESOURCE_REQUEST, and I don't know why I should be using # here, but I think


@PART_DEFINITION
[*]:HAS[#part[cupola]
{
@part = cupola
}
@RESOURCE_REQUEST
[*]:HAS[#name[Xenon_Gas]]
{
@Name = XenonGas}
}

should work?

Link to comment
Share on other sites

So I want to replace a value in one module, but only if two AND conditions are met in a different module. The example code below will make MM give an error on the load screen, but it actually works exactly how I want and I see the changes I made in the game, as intended.

MMTEST is the main config file, @MMTEST contains the edits, and MMEXPECTED gives the actual results of the code.

The error happens because one of the @dislikes edits in @MMTEST will give an empty value. However, MM seems to simply ignore the empty value and just keep the default value or the most recent edit, which is what I want. But I get an error message on the loading screen.

Does anyone know how to get rid of the error (since it gives me the desired result)? Or can show me the correct way to write my code?

// Test for replacing values given two AND conditons that may or may not be satisfied

// Main config file
MMTEST
{
ANIMAL
{
id = Dog // no "name" values
fourLegs = True
dislikes = Andy
}
ANIMAL
{
id = Bird
fourLegs = False
dislikes = Andy
}
ANIMAL
{
id = Cat
fourLegs = True
dislikes = Andy
}
}


// Module Manager editing file
// Want to change "dislike" value for Bird and Cat to the animal that comes before it, if fourLegs = True.
// Gives error when both conditions are not met, because the edit will give an empty value (i.e. "dislike = ")
// This happens at **
@MMTEST
{
@ANIMAL:HAS[#id[Bird]]
{
// # (search for), $~$ (copy value), /~/ (directory navigation)
@dislikes = #$/ANIMAL:HAS[#id[Dog]fourLegs[True]]/id$
}
@ANIMAL:HAS[#id[Cat]]
{
@dislikes = #$/ANIMAL:HAS[#id[Dog]fourLegs[True]]/id$
@dislikes = #$/ANIMAL:HAS[#id[Bird]fourLegs[True]]/id$ // **
}
}


// Expected outcome
MMEXPECTED
{
MMTEST
{
ANIMAL
{
id = Dog // no "name" values
fourLegs = True
dislikes = Andy
}
ANIMAL
{
id = Bird
fourLegs = False
dislikes = Dog
}
ANIMAL
{
id = Cat
fourLegs = True
dislikes = Dog
}
}
}

Link to comment
Share on other sites

So I want to replace a value in one module, but only if two AND conditions are met in a different module. The example code below will make MM give an error on the load screen, but it actually works exactly how I want and I see the changes I made in the game, as intended.

MMTEST is the main config file, @MMTEST contains the edits, and MMEXPECTED gives the actual results of the code.

The error happens because one of the @dislikes edits in @MMTEST will give an empty value. However, MM seems to simply ignore the empty value and just keep the default value or the most recent edit, which is what I want. But I get an error message on the loading screen.

Does anyone know how to get rid of the error (since it gives me the desired result)? Or can show me the correct way to write my code?

// Test for replacing values given two AND conditons that may or may not be satisfied

// Main config file
MMTEST
{
ANIMAL
{
id = Dog // no "name" values
fourLegs = True
dislikes = Andy
}
ANIMAL
{
id = Bird
fourLegs = False
dislikes = Andy
}
ANIMAL
{
id = Cat
fourLegs = True
dislikes = Andy
}
}


// Module Manager editing file
// Want to change "dislike" value for Bird and Cat to the animal that comes before it, if fourLegs = True.
// Gives error when both conditions are not met, because the edit will give an empty value (i.e. "dislike = ")
// This happens at **
@MMTEST
{
@ANIMAL:HAS[#id[Bird]]
{
// # (search for), $~$ (copy value), /~/ (directory navigation)
@dislikes = #$/ANIMAL:HAS[#id[Dog]fourLegs[True]]/id$
}
@ANIMAL:HAS[#id[Cat]]
{
@dislikes = #$/ANIMAL:HAS[#id[Dog]fourLegs[True]]/id$
@dislikes = #$/ANIMAL:HAS[#id[Bird]fourLegs[True]]/id$ // **
}
}


// Expected outcome
MMEXPECTED
{
MMTEST
{
ANIMAL
{
id = Dog // no "name" values
fourLegs = True
dislikes = Andy
}
ANIMAL
{
id = Bird
fourLegs = False
dislikes = Dog
}
ANIMAL
{
id = Cat
fourLegs = True
dislikes = Dog
}
}
}

A variable lookup that hits an empty result set is reported as an error because your "apply this edit only if there's something in the result set" use case is literally the only pattern where you would want the behavior.

I happen to recall that you can OR multiple groups of criteria together in one HAS block, so if you want to access "the first of Dog or Bird that has fourLegs = true", you can write that as one line:

@dislikes = #$/ANIMAL:HAS[#id[Dog]fourLegs[True]|#id[bird]fourLegs[True]],0/id$

Link to comment
Share on other sites

A variable lookup that hits an empty result set is reported as an error because your "apply this edit only if there's something in the result set" use case is literally the only pattern where you would want the behavior.

I happen to recall that you can OR multiple groups of criteria together in one HAS block, so if you want to access "the first of Dog or Bird that has fourLegs = true", you can write that as one line:

@dislikes = #$/ANIMAL:HAS[#id[Dog]fourLegs[True]|#id[bird]fourLegs[True]],0/id$

Didn't work:( It works if only the first AND or both ANDs are true (either results in the /id for the first AND), but I get an error if only the second AND is true and the value defaults, which is not desired behavior.

Is there any way to write

MODULE:HAS[(#A AND #True) OR (#B AND #True) OR (#C AND #True) OR ...],0?

Edit:

​The following doesn't seem to work either. I get the same pattern of errors as above.

@dislikes = #$/ANIMAL:HAS[#id[Dog]|#id[bird]fourLegs[True]],0/id$

I was trying for

MODULE:HAS[(#A OR #B OR #C OR ...) AND #True],0

Edited by ev0
Link to comment
Share on other sites

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