Jump to content

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


sarbian

Recommended Posts

6 minutes ago, toric5 said:

im trying to nerf reaction wheels in my install, and i have this code so far:


//nerfing reaction wheels
@PART[*]:HAS[ModuleReactionWheel]
{
	@MODULE[ModuleReactionWheel]
	{
		@PitchTorque /=2
		@YawTorque /=2
		@RollTorque /=2
	}
}

why is this not working?

Because it should be :HAS[@MODULE[ModuleReactionWheel]]

Link to comment
Share on other sites

I think I just found a small bug:

I had reports that KWRocketry had issues with one of the tech node missing, so I investigated and found the following:

This is the original syntax:

RDNode :NEEDS[!CommunityTechTree&!B9_Aerospace]

The above syntax was not working, in that it was not seeing that both the CommunityTechTree & B9_Aerospace were not installed.  It appears that a space is needed on each side of the ampersand as follows:

RDNode :NEEDS[!CommunityTechTree & !B9_Aerospace]

which does work.

Link to comment
Share on other sites

1 hour ago, linuxgurugamer said:

I think I just found a small bug:

I had reports that KWRocketry had issues with one of the tech node missing, so I investigated and found the following:

This is the original syntax:


RDNode :NEEDS[!CommunityTechTree&!B9_Aerospace]

The above syntax was not working, in that it was not seeing that both the CommunityTechTree & B9_Aerospace were not installed.  It appears that a space is needed on each side of the ampersand as follows:


RDNode :NEEDS[!CommunityTechTree & !B9_Aerospace]

which does work.

Apparently the spaces cause errors.

The following worked individually:

RDNode :NEEDS[&!B9_Aerospace]

and


RDNode :NEEDS[!CommunityTechTree]

but together, it fails.  

Link to comment
Share on other sites

10 minutes ago, linuxgurugamer said:

Apparently the spaces cause errors.

The following worked individually:


RDNode :NEEDS[&!B9_Aerospace]

and


RDNode :NEEDS[!CommunityTechTree]

but together, it fails.  

Try

:NEEDS[!mod1,!mod2]

I've used it in the past and it always worked

I don't know if the underscore might cause any issues

Link to comment
Share on other sites

3 minutes ago, Sigma88 said:

Try

:NEEDS[!mod1,!mod2]

I've used it in the past and it always worked

I don't know if the underscore might cause any issues

I'll try it, but the & is valid syntax and used to work in the past

 

3 minutes ago, linuxgurugamer said:

I'll try it, but the & is valid syntax and used to work in the past

 

this did not work:

	RDNode:NEEDS[!CommunityTechTree,!B9_Aerospace]

 

Link to comment
Share on other sites

18 minutes ago, linuxgurugamer said:

I'll try it, but the & is valid syntax and used to work in the past

 

this did not work:


	RDNode:NEEDS[!CommunityTechTree,!B9_Aerospace]

 

Try using 

B9?Aerospace

Maybe it's the underscore that is giving you issues

Link to comment
Share on other sites

Hmm, after more work, it seems that there is something going on with this.  It appears that the game I'm testing in thinks that B9 is installed, even though they are not.

I'm trying the ? instead of the _ now

 

Edit:  That seems to do it, I'll update the issue on github.  Again, this used to work, now doesn't

Edited by linuxgurugamer
Link to comment
Share on other sites

1 minute ago, linuxgurugamer said:

Hmm, after more work, it seems that there is something going on with this.  It appears that the game I'm testing in thinks that B9 ais installed, even though they are not.

I'm trying the ? instead of the _ now

If you delete mm cache and run the game, then upload the ksp.log I can take a look for you :wink:

Link to comment
Share on other sites

1 minute ago, Sigma88 said:

If you delete mm cache and run the game, then upload the ksp.log I can take a look for you :wink:

No need now, the ? replacing the _ fixed the problem.

I'll do more testing this evening, have to go to work now.

thanks

Link to comment
Share on other sites

 

so im trying to add lithium conversion into all ISRUs that are able to make monopropellant. couple of problems. this should be targeting the module i need it to (anything that can convert ore into mono), but it does not seem to. anything blatanly wrong? ive been beating my head against it for a while, and fournd a few things, but even with them removed, still does not get the things i want it to. 

also need to add an exclusion for things that already have an ore to lithium converter, but if i can figure out whats wrong with this, i think i can do that.

second, how to i import the values for the monoprop converter, then multiply them by certain values? (see code)

//adding NFP ISRU stuff to all mono prop ISRUs
@PART[*]:HAS[@MODULE[ModuleResourceConverter]:HAS[@OUTPUT_RESOURCE[Monoprop]&@INPUT_RESOURCE[Ore]]]

{
   
	MODULE
	{
		name = ModuleResourceConverter
		ConverterName = Lithium
		StartActionName = Start ISRU [Li]
		StopActionName = Stop ISRU [Li]
		AutoShutdown = //samevalue
		TemperatureModifier
		{
			key = //samevalues
			key = //samevalues
			key = //samevalues
			key = //samevalues
			key = //samevalues
			key = //samevalues
		}
		 
		GeneratesHeat = //samevalues
		ThermalEfficiency
		{
			key = //samevalues
			key = //samevalues
			key = //samevalues
			key = //samevalues
			key = //samevalues
		}
		DefaultShutoffTemp = //samevalues
		UseSpecialistBonus = //samevalues
		SpecialistEfficiencyFactor = //samevalues
		SpecialistBonusBase = //samevalues
		Specialty = Engineer
		EfficiencyBonus = //samevalues


		INPUT_RESOURCE
		{
			ResourceName = Ore
			Ratio = //oreinputValue*2
			FlowMode = STAGE_PRIORITY_FLOW
		}
		INPUT_RESOURCE
		{
			ResourceName = ElectricCharge
			Ratio = //electricinputValue*.6
		}
		OUTPUT_RESOURCE
		{
			ResourceName = Lithium
			Ratio = //monpropOutput*18
			DumpExcess = false
			FlowMode = STAGE_PRIORITY_FLOW
		}
	}
}

 

Edited by toric5
Link to comment
Share on other sites

Apropos of absolutely nothing, I felt it was time to pop in and marvel at how powerful, useful, and flexible module manager is. it's truly a unique work that supports and drives so much of this community. 

Thank you to everyone who has contributed to it's advancement, and thank you to Sarbian for his long suffering support and stewardship.

Link to comment
Share on other sites

I like to find the index number of "LiquidFuel,Oxidizer" to use this number to extract the values in a another index field:

Quote

    MODULE
    {
        name = FSfuelSwitch
        resourceNames = Karborundum;XenonGas;ArgonGas;LiquidFuel,Oxidizer;Water;Chemicals;Mulch;LqdHydrogen;LiquidFuel;MonoPropellant
        resourceAmounts = 100000;1000000;10000000;9000,11000;100000;100000;100000;400000;20000;20000

In this case I need 9000 and 11000 to further work with.

Quote

    MODULE
    {
        name = InterstellarFuelSwitch
        resourceNames = Structural;LiquidFuel;LiquidFuel,Oxidizer;MonoPropellant
        resourceAmounts = 0;800;360,440;800

In this case I need 360 and 440 to further work with.

Is this possible with MM?

Edited by Kolago
Link to comment
Share on other sites

On Tuesday, May 24, 2016 at 6:38 PM, toric5 said:

 

so im trying to add lithium conversion into all ISRUs that are able to make monopropellant. couple of problems. this should be targeting the module i need it to (anything that can convert ore into mono), but it does not seem to. anything blatanly wrong? ive been beating my head against it for a while, and fournd a few things, but even with them removed, still does not get the things i want it to. 

also need to add an exclusion for things that already have an ore to lithium converter, but if i can figure out whats wrong with this, i think i can do that.

second, how to i import the values for the monoprop converter, then multiply them by certain values? (see code)

 

I'm no expert, but something like this is what I would have thought

Spoiler

@PART[*]:HAS[@MODULE[ModuleResourceConverter]:HAS[@OUTPUT_RESOURCE[*]:HAS[#ResourceName[MonoPropellant]]]]:FINAL
{
   +MODULE[ModuleResourceConverter]:HAS[@OUTPUT_RESOURCE[*]:HAS[#ResourceName[MonoPropellant]]]
   {
        @ConverterName = Lithium
        @StartActionName = Start ISRU [Li]
        @StopActionName = Stop ISRU [Li]
        @Specialty = Engineer
        @INPUT_RESOURCE:HAS[#ResourceName[Ore]]
        {
            @Ratio *= 2
            %FlowMode = STAGE_PRIORITY_FLOW
        }
        @INPUT_RESOURCE:HAS[#ResourceName[ElectricCharge]]
        {
            @Ratio *= .6
        }
        @OUTPUT_RESOURCE
        {
            @ResourceName = Lithium
            @Ratio *= 18
            @DumpExcess = false
            %FlowMode = STAGE_PRIORITY_FLOW
        }
    }
}

In testing though, I can't seem to get the nested :HAS conditions to work at all. Is this a bug perhaps?

Link to comment
Share on other sites

9 hours ago, Kolago said:

I like to find the index number of "LiquidFuel,Oxidizer" to use this number to extract the values in a another index field:

In this case I need 9000 and 11000 to further work with.

In this case I need 360 and 440 to further work with.

Is this possible with MM?

9 hours ago, blowfish said:

@Kolago I don't believe that's possible, no.  Unless you want to make a separate patch for each possible position.

 

here's how you can do it :D

// This is just a dummy part to edit with the patch
PART
{
	MODULE
	{
		name = test
		testlist = a;b;c,d;e;f
		testvalues = 1;2;3,4;5;6
	}
	MODULE
	{
		name = test
		testlist = v;c,d;x;y;z
		testvalues = 9;8,7;6;5;4
	}
}


// This is the actual patch

@PART:HAS[@MODULE[test]]
{
	@MODULE:HAS[#name[test]]
	{
		@testlist = #$testlist$;endlist
		@testvalues = #$testvalues$;endlist
		
		!newlist,* = DEL
		newlist = startlist;
		
		!newvalues,* = DEL
		newvalues = startlist;
		
		!readlist,* = DEL
		readlist = #$testlist[0,;]$
	}
}
@PART:HAS[@MODULE[test]:HAS[#testlist[*]]]
{
	@MODULE[test]:HAS[#readlist[c,d]]
	{
		%targetvalue = #$testvalues[0,;]$
		@targetvalue[0] += 10
		@targetvalue[1] += 20
		@testvalues[0,;] = #$targetvalue$
		!targetvalue,* = DEL
	}
	@MODULE[test]:HAS[~readlist[endlist]]
	{
		@newlist = #$newlist$$testlist[0,;]$;
		@newvalues = #$newvalues$$testvalues[0,;]$;
		@testlist[0,;] = startlist
		@testvalues[0,;] = startlist
		@testlist ^= :startlist;::
		@testvalues ^= :startlist;::
		%readlist = #$testlist[0,;]$
	}
	@MODULE[test]:HAS[#readlist[endlist]]
	{
		!testlist,* = DEL
		!testvalues,* = DEL
		!readlist,* = DEL
		@newlist ^= :startlist;::
		@newvalues ^= :startlist;::
	}
	MM_PATCH_LOOP {}
}
@PART:HAS[@MODULE[test]]
{
	@MODULE:HAS[#name[test]]
	{
		testlist = #$newlist$endlist
		testvalues = #$newvalues$endlist
		@testlist ^= :;endlist::
		@testvalues ^= :;endlist::
		!newlist = DEL
		!newvalues = DEL
	}
}

 

this is just a proof of concept, you will need to change all the parameters to match your situation

let me know if you need a hand doing so :wink:

 

This patch will add respectively 10 and 20 to the c and d parameters contained in the "slot"   ;c,d;

the resulting PART will be:

UrlConfig
{
	name = PART
	type = PART
	parentUrl = /test
	url = /test/PART
	PART
	{
		MODULE
		{
			name = test
			testlist = a;b;c,d;e;f
			testvalues = 1;2;13,24;5;6
		}
		MODULE
		{
			name = test
			testlist = v;c,d;x;y;z
			testvalues = 9;18,27;6;5;4
		}
	}
}

 

Edited by Sigma88
Link to comment
Share on other sites

12 hours ago, Chris97b said:

I'm no expert, but something like this is what I would have thought

  Hide contents

@PART[*]:HAS[@MODULE[ModuleResourceConverter]:HAS[@OUTPUT_RESOURCE[*]:HAS[#ResourceName[MonoPropellant]]]]:FINAL
{
   +MODULE[ModuleResourceConverter]:HAS[@OUTPUT_RESOURCE[*]:HAS[#ResourceName[MonoPropellant]]]
   {
        @ConverterName = Lithium
        @StartActionName = Start ISRU [Li]
        @StopActionName = Stop ISRU [Li]
        @Specialty = Engineer
        @INPUT_RESOURCE:HAS[#ResourceName[Ore]]
        {
            @Ratio *= 2
            %FlowMode = STAGE_PRIORITY_FLOW
        }
        @INPUT_RESOURCE:HAS[#ResourceName[ElectricCharge]]
        {
            @Ratio *= .6
        }
        @OUTPUT_RESOURCE
        {
            @ResourceName = Lithium
            @Ratio *= 18
            @DumpExcess = false
            %FlowMode = STAGE_PRIORITY_FLOW
        }
    }
}

In testing though, I can't seem to get the nested :HAS conditions to work at all. Is this a bug perhaps?

im basing it on this:

@PART[*]:HAS[ @MODULE[ModuleEngines] :HAS [ @PROPELLANT[XenonGas] , @PROPELLANT[ElectricCharge] ] ]

straight from the MM handbook. any long time users want to help a newbie modder out?

Link to comment
Share on other sites

1 hour ago, Kolago said:

How do I get the values out in to another MODULE ?


    MODULE
    {
        name = ModuleFuelTanks
        volume = LF + Ox ?????
        type = Default
    }

 

depends on where the other MODULE is

could you give a bit more info?

like, is the other MODULE in the same PART? is it a brand new MODULE or does it already exist? which values exactly do you want to copy?

Edited by Sigma88
Link to comment
Share on other sites

42 minutes ago, toric5 said:

im basing it on this:

@PART[*]:HAS[ @MODULE[ModuleEngines] :HAS [ @PROPELLANT[XenonGas] , @PROPELLANT[ElectricCharge] ] ]

straight from the MM handbook. any long time users want to help a newbie modder out?

Yeah, that should work, but I doubt you can do :HAS[@OUTPUT_RESOURCE[MonoPropellant]] as the key for that is actually ResourceName as opposed to just name. The way I understand it the @MODULE[modulename] is just shorthand for a module with key 'name' and value 'modulename'. Hence the @OUTPUT_RESOURCE[*]:HAS[#ResourceName[MonoPropellant]]

I tested it several ways though and couldn't get it to work. It always matches either all parts with a ModuleResourceConverter (including non-monoprop ones), or no parts at all.

Link to comment
Share on other sites

2 minutes ago, Chris97b said:

Yeah, that should work, but I doubt you can do :HAS[@OUTPUT_RESOURCE[MonoPropellant]] as the key for that is actually ResourceName as opposed to just name. The way I understand it the @MODULE[modulename] is just shorthand for a module with key 'name' and value 'modulename'. Hence the @OUTPUT_RESOURCE[*]:HAS[#ResourceName[MonoPropellant]]

I tested it several ways though and couldn't get it to work. It always matches either all parts with a ModuleResourceConverter (including non-monoprop ones), or no parts at all.

what matched it with everything? i havent even got that...

Link to comment
Share on other sites

8 minutes ago, toric5 said:

what matched it with everything? i havent even got that...

I've been playing with it in a test environment with just NFP installed (and NFP's config for the stock ISRU disabled). This one is the one that matches them all, but it is admittedly malformed. It was just one of the things I was testing.

Spoiler

@PART[*]:HAS[@MODULE[ModuleResourceConverter]]:HAS[@OUTPUT_RESOURCE[*]]:HAS[#ResourceName[MonoPropellant]]:FINAL

 

[LOG 13:12:10.390] [ModuleManager] Applying node /NFP/@PART[*]:HAS[@MODULE[ModuleResourceConverter]]:HAS[@OUTPUT_RESOURCE[*]]:HAS[#ResourceName[MonoPropellant]]:FINAL to Squad/Parts/Resources/FuelCell/FuelCell/FuelCell
[LOG 13:12:10.391] [ModuleManager] Applying node /NFP/@PART[*]:HAS[@MODULE[ModuleResourceConverter]]:HAS[@OUTPUT_RESOURCE[*]]:HAS[#ResourceName[MonoPropellant]]:FINAL to Squad/Parts/Resources/FuelCell/FuelCellArray/FuelCellArray
[LOG 13:12:10.392] [ModuleManager] Applying node /NFP/@PART[*]:HAS[@MODULE[ModuleResourceConverter]]:HAS[@OUTPUT_RESOURCE[*]]:HAS[#ResourceName[MonoPropellant]]:FINAL to Squad/Parts/Resources/ISRU/ISRU/ISRU
[LOG 13:12:10.393] [ModuleManager] Applying node /NFP/@PART[*]:HAS[@MODULE[ModuleResourceConverter]]:HAS[@OUTPUT_RESOURCE[*]]:HAS[#ResourceName[MonoPropellant]]:FINAL to Squad/Parts/Resources/MiniISRU/MiniISRU/MiniISRU

Note that it applies to the stock fuel cell as well as the ISRUs, which to me means that as soon as the :HAS[@MODULE[ModuleResourceConverter]] is met, then it matches.

As I said though, this *shouldn't* work, I was just testing things.

Link to comment
Share on other sites

3 hours ago, Sigma88 said:

depends on where the other MODULE is

could you give a bit more info?

like, is the other MODULE in the same PART? is it a brand new MODULE or does it already exist? which values exactly do you want to copy?

Ok, here is what I have so far, but it doesnt work:

@PART[*]:HAS[@MODULE[FSfuelSwitch]]
{	
	@MODULE[FSfuelSwitch]
	{
		@resourceNames = #$resourceNames$;endlist
		@resourceAmounts = #$resourceAmounts$;endlist
		newlist = startlist;
		newvalues = startlist;
		readlist = #$resourceNames[0,;]$
	}
}

@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#resourceNames[*]]]
{
	@MODULE[FSfuelSwitch]:HAS[#readlist[LiquidFuel,Oxidizer]]
	{
		%targetvalue = #$resourceAmounts[0,;]$
		@volume += #$targetvalue[0]$
		@volume += #$targetvalue[1]$
		@resourceAmounts[0,;] = #$targetvalue$
		!targetvalue,* = DEL
	}

	@MODULE[FSfuelSwitch]:HAS[~readlist[endlist]]
	{
		@newlist = #$newlist$$resourceNames[0,;]$;
		@newvalues = #$newvalues$$resourceAmounts[0,;]$;
		@resourceNames[0,;] = startlist
		@resourceAmounts[0,;] = startlist
		@resourceNames ^= :startlist;::
		@resourceAmounts ^= :startlist;::
		%readlist = #$resourceNames[0,;]$
	}
	@MODULE[FSfuelSwitch]:HAS[#readlist[endlist]]
	{
		!resourceNames,* = DEL
		!resourceAmounts,* = DEL
		!readlist,* = DEL
		@newlist ^= :startlist;::
		@newvalues ^= :startlist;::
	}
	MM_PATCH_LOOP {}
}

@PART[*]:HAS[@MODULE[FSfuelSwitch]]
{
	@MODULE[FSfuelSwitch]
	{
		resourceNames = #$newlist$endlist
		resourceAmounts = #$newvalues$endlist
		@resourceNames ^= :;endlist::
		@resourceAmounts ^= :;endlist::
		!newlist = DEL
		!newvalues = DEL
	}
}

@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#volume[>0]],@MODULE[ModuleFuelTanks]]:NEEDS[modularFuelTanks]
{
	MODULE
	{
		name = ModuleFuelTanks
		volume = #$../@MODULE[FSfuelSwitch]/volume$
		type = Default
	}
	!MODULE[FSfuelSwitch] {}
}

I like to end up with a new modul ModuleFuelTanks and delete FSfuelSwitch at the end.

I see some

MM_PATCH_LOOP
        {
        }

in the ConfigCache, but no modul ModuleFuelTanks.

Edited by Kolago
Link to comment
Share on other sites

New version with your change and replacement of

@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#volume[>0]],@MODULE[ModuleFuelTanks]]:NEEDS[modularFuelTanks]

with

@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#volume[>0]]]:NEEDS[modularFuelTanks]

@PART[*]:HAS[@MODULE[FSfuelSwitch]]
{	
	@MODULE[FSfuelSwitch]
	{
		@resourceNames = #$resourceNames$;endlist
		@resourceAmounts = #$resourceAmounts$;endlist
		newlist = startlist;
		newvalues = startlist;
		readlist = #$resourceNames[0,;]$
	}
}

@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#resourceNames[*]]]
{
	@MODULE[FSfuelSwitch]:HAS[#readlist[LiquidFuel,Oxidizer]]
	{
		%targetvalue = #$resourceAmounts[0,;]$
		%volume = #$targetvalue[0]$
		@volume += #$targetvalue[1]$
		@resourceAmounts[0,;] = #$targetvalue$
		!targetvalue,* = DEL
	}

	@MODULE[FSfuelSwitch]:HAS[~readlist[endlist]]
	{
		@newlist = #$newlist$$resourceNames[0,;]$;
		@newvalues = #$newvalues$$resourceAmounts[0,;]$;
		@resourceNames[0,;] = startlist
		@resourceAmounts[0,;] = startlist
		@resourceNames ^= :startlist;::
		@resourceAmounts ^= :startlist;::
		%readlist = #$resourceNames[0,;]$
	}
	@MODULE[FSfuelSwitch]:HAS[#readlist[endlist]]
	{
		!resourceNames,* = DEL
		!resourceAmounts,* = DEL
		!readlist,* = DEL
		@newlist ^= :startlist;::
		@newvalues ^= :startlist;::
	}
	MM_PATCH_LOOP {}
}

@PART[*]:HAS[@MODULE[FSfuelSwitch]]
{
	@MODULE[FSfuelSwitch]
	{
		resourceNames = #$newlist$endlist
		resourceAmounts = #$newvalues$endlist
		@resourceNames ^= :;endlist::
		@resourceAmounts ^= :;endlist::
		!newlist = DEL
		!newvalues = DEL
	}
}

@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#volume[>0]]]:NEEDS[modularFuelTanks]
{
	MODULE
	{
		name = ModuleFuelTanks
		volume = #$../@MODULE[FSfuelSwitch]/volume$
		type = Default
	}
	!MODULE[FSfuelSwitch] {}
}

Now i get some errors in the log:

[ModuleManager] Applying node Kolago/MM_FSFS_to_MFT/@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#volume[>0]]] to NSS/Parts/OctoSat_Sc_TopDish/OctoSat_Sc_TopDish
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

[ModuleManager] Can't find nodeType:MODULE
 
(Filename: C:/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 64)

[ModuleManager] Error - Cannot parse variable search when inserting new key volume = #$../@MODULE[FSfuelSwitch]/volume$

volume = #$../@MODULE[FSfuelSwitch]/volume$ is wrong, but how do I get the value out of the modul?

Edited by Kolago
Link to comment
Share on other sites

16 minutes ago, Kolago said:

volume = #$../@MODULE[FSfuelSwitch]/volume$ is wrong, but how do I get the value out of the modul?

you don't need the

volume = #$../MODULE[FSfuelSwitch]/volume$

 

I should have spotted that before :) 

Edited by Sigma88
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...