Jump to content

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


sarbian

Recommended Posts

I'm trying to do math on a part using values from a RESOURCE_DEFINITION:

[...]

Is there some syntax error I'm missing, or are RESOURCE_DEFINITION nodes not accessible while patching a part?

Nope, there was a bug and I just fixed it. Thanks for the report.

2.5.3 is out

Link to comment
Share on other sites

Are there smaller or equal and bigger or equal argument ?

I would like to write something that would search @PART[*]:HAS[#mass[<.5]] for KAS

While I am at it, I'm sure you posted all this already but I can't find the good keyword to find it, is there a way to use the math operators and to set a dependancies on another value. I'm looking specifically at writing something that could add as example fuel to every wing in function of it's original mass.

@PART[*]

@RESOURCE[LiquidFuel]{

@amount = {something adressing the part's mass *ratio ?}

@maxamount = {}}

EDIT: I saw that NathanKell was doing something similar in modularfuelsystem, but I'm not sure if his equation are depending on MM or if it is his dll that allows it ( I don't think it's relying on MM )

EDIT AGAIN: Ok I realise it's probably not possible, somebody would have done it before, stuff like

@PART[*]:HAS[RESOURCE[LiquidFuel]]| (etc...)

{!RESOURCE[*]{} }

@MODULE[FSfuelSwitch]

{

@resourceNames = Structural;LiquidFuel;LiquidFuel,Oxidizer

@resourceAmounts = 0;0.000508*mass;0.00113*mass;0.00924*mass

@basePartMass = mass

@tankMass = mass;mass*someratio;mass*someratio

@tankCost = cost;cost*someratio;cost*someratio

@displayCurrentTankCost = true

@hasGUI = False

@showInfo = false

}

EDIT ALL OVER: Reading throught the thread I'm starting to get it, it would look more like

@PART[*]:HAS[@RESOURCE[MonoPropellant]] // I'm not sure about or, would HAS[@RESOURCE[MonoPropellant|LiquidFuel|Oxidizer]] work ?

{

@MODULE[FSfuelSwitch]

{

resourceNames = Structural;LiquidFuel;LiquidFuel,Oxidizer;MonoPropellant

resourceAmounts = 0;0;0,0;0

@resourceAmounts += 0;#$/RESOURCE[LiquidFuel]/amount$;#$/RESOURCE[LiquidFuel]/amount$,#$/RESOURCE[LiquidFuel]/amount$;#$/RESOURCE[LiquidFuel]/amount$

@resourceAmounts += 0;#$/RESOURCE[Oxidizer]/amount$;#$/RESOURCE[Oxidizer]/amount$,#$/RESOURCE[Oxidizer]/amount$;#$/RESOURCE[Oxidizer]/amount$

@resourceAmounts += 0;#$/RESOURCE[MonoPropellant]/amount$;#$/RESOURCE[MonoPropellant]/amount$,#$/RESOURCE[MonoPropellant]/amount$;#$/RESOURCE[MonoPropellant]/amount$

@resourceAmounts *= 0;1;0.45,0.55;1

tankMass = 0;#$/mass$;#$/mass$;#$/mass$

@tankMass *= 0;0.1;0.2;0.1

tankCost = 0;#$/cost$;#$/cost$;#$/cost$

@tankCost *= 0;0.1;0.2;0.1

displayCurrentTankCost = true

hasGUI = False

showInfo = false

}

!RESOURCE[MonoPropellant]{}

}

I'm not sure of how to handle the ";" of FSfuelswitch, would it work like that or do I have to adress each value separately by using the index option ( still reading )

So the index options are just working one way ? I can copy a value from a specific position on the line, how to paste/add a value in a specific position in a row like

stuff = 0;1;2;3

@stuff[1,;] += 1

and then the second entry would become a 2!!! I can't even make this work right now

About the smaller or equal argument, could I set up an interval @PART[*]:HAS[#mass[0-2]]

I'm so new to this.... What is the link between MM and Regext ( cause I saw a lot of mention of it without understanding) , is it like MM is a regext based thing and therefore regext arguments are working in it, or is it just that regext is an awesome tool to generate config files for MM

EDIT: INSOMNIA: Is it possible that what i am trying to do was originally not intended because using @PART[*] and therefore going through every part is not loading friendly ? If it is the case, caching would kill such problem ?

I realise this is a lot of probably stupid and annoying questions that might never get answered, and i don't mean to bug you with this sarbian, you're work is absolutely awesome!!!

Edited by Saint-Stanislas
Link to comment
Share on other sites

Is there a maximum of configs that can be processed?? I hangup at 6410 patches.

This is getting out of hand. I dont remember seeing a limit anywhere in the code. Do you freeze up at exactly 6410? It might be useful to have a log if you have it.

Link to comment
Share on other sites

This is getting out of hand. I dont remember seeing a limit anywhere in the code. Do you freeze up at exactly 6410? It might be useful to have a log if you have it.

Actually I fixed it. :) It has nothing to do with Module Manager. Some modder forgot the ' } ' in their mod. It was a serious pain the @r$e to find.

Edited by Master Tao
better way to say that
Link to comment
Share on other sites

Actually I fixed it. :) It has nothing to do with Module Manager. Some modder forgot the ' } ' in their mod. It was a serious pain the @r$e to find.

Notepad++ is a good way to check for that. Do a search for { and click the count button. Then search for } and click the count button. If they don't match, problem :)

Link to comment
Share on other sites

I'm trying to make a MM patch that adds some stuff to every probe core in my game, instead of having to go through and look up the part names of all the various probes that my plethora of mods adds, I was hoping to be able to use the wildcard functions to get this done.

I'm starting to think what I'm asking isn't possible given that mods like RT go through and name every probe, but who knows maybe I'll get lucky.

So the obvious problem is that the only thing that really differentiates a probe core from a command pod is the minnimumCrew = 0 variable in the ModuleCommand node.

I was hoping I could do something like


@PART
[*]:HAS[@MODULE[ModuleCommand]:HAS[minimumCrew = 0]]
{
...stuff
}

or

@PART
[*]:HAS[@MODULE[ModuleCommand]:HAS[@minimumCrew[0]]]
{
....stuff
}

so far those and various other set ups like that have not worked, I believe this is because the HAS function looks for nodes, like MODULE or RESOURCE nodes, and minnimumCrew is a variable defined in a node.

Is there a way to accomplish what I am trying to do that I am simply unaware of, or do I just need to stop being lazy and go dig through my GameData folder and find the part names for all my probes? Of course at that point I might as well just add my stuff to the configs instead of using MM to do it since this is just for personal use and not intended to be distributed.:P

Cheers

EDIT:And the answer was found in the signature of the poster right above me! Thank you Starwaster!


@PART
[*]:HAS[@MODULE[ModuleCommand]:HAS[#minimumCrew[0]]]
{
...stuff
}

not the way you did it in your Probe Science configs but I noticed you were using the # operator, so I decided to give that a try:D

Which leads me to the question: What is the # operator, what does it do?

I haven't done any programming since my high school C++ class so if I knew its a standardized kind of thing I no longer remember and I looked through the OP and the GitHub documentation wiki and couldn't find any info on it.

Edited by Akira_R
Link to comment
Share on other sites

I'm trying to make a MM patch that adds some stuff to every probe core in my game, instead of having to go through and look up the part names of all the various probes that my plethora of mods adds, I was hoping to be able to use the wildcard functions to get this done.

I'm starting to think what I'm asking isn't possible given that mods like RT go through and name every probe, but who knows maybe I'll get lucky.

So the obvious problem is that the only thing that really differentiates a probe core from a command pod is the minnimumCrew = 0 variable in the ModuleCommand node.

I was hoping I could do something like


@PART
[*]:HAS[@MODULE[ModuleCommand]:HAS[minimumCrew = 0]]
{
...stuff
}

or

@PART
[*]:HAS[@MODULE[ModuleCommand]:HAS[@minimumCrew[0]]]
{
....stuff
}

so far those and various other set ups like that have not worked, I believe this is because the HAS function looks for nodes, like MODULE or RESOURCE nodes, and minnimumCrew is a variable defined in a node.

Is there a way to accomplish what I am trying to do that I am simply unaware of, or do I just need to stop being lazy and go dig through my GameData folder and find the part names for all my probes? Of course at that point I might as well just add my stuff to the configs instead of using MM to do it since this is just for personal use and not intended to be distributed.:P

Cheers

A selector inside a :HAS[] can look for either a subnode or a value, depending on what punctuation you use. I think the right spelling for your selector is @PART[*]:HAS[@MODULE[ModuleCommand]:HAS[#minimumCrew[0]]].

Link to comment
Share on other sites

So , reading through almost everything about MM, I found some good examples and info

This post in particular should be linked on the first page, it took me a while to dig it up and it has enlightened my understanding really much Sarbian's MM syntax update

So I'm just pasting what I've found out to work when you want to add a FSfuelswitch module with relative quantities. It's still incomplete but I hope it gives you guys a bunch of idea of what MM could do for us.

@PART[*]:HAS[@RESOURCE[LiquidFuel]]:FINAL

{

ValueZero = 0 //used to replace unfinished stuff

TotalLiters = 0 //Capacity

@TotalLiters += #$/RESOURCE[LiquidFuel]/maxAmount$ //Adding every maxAmount of fuel we mess with to capacity

@TotalLiters += #$/RESOURCE[Oxidizer]/maxAmount$

@TotalLiters += #$/RESOURCE[Karbonite]/maxAmount$

@TotalLiters += #$/RESOURCE[MonoPropellant]/maxAmount$

@TotalLiters += #$/RESOURCE[LqdMethane]/maxAmount$

@TotalLiters += #$/RESOURCE[Water]/maxAmount$

@TotalLiters += #$/RESOURCE[Ammonia]/maxAmount$

@TotalLiters += #$/RESOURCE[RocketParts]/maxAmount$

@TotalLiters += #$/RESOURCE[Ore]/maxAmount$

@TotalLiters += #$/RESOURCE[Metal]/maxAmount$

//LitersRocketPartsMetal = #$/TotalLiters$ //not sure about the ratio so not using

//@LitersRocketPartsMetal *= 1.5

//LitersOre = #$/TotalLiters$

//@LitersOre *= 5 //not sure about the ratio so not using

TotalLiquOx = #$/TotalLiters$ //creating partial amounts for multi-fuel tank

@TotalLiquOx *= 0.45 //ratio for Liquid when with Oxidizer

TotalOxLiqu = #$/TotalLiters$

@TotalOxLiqu *= 0.55 //ratio for Oxidizer when with Liquid

TotalMethOx = #$/TotalLiters$

@TotalMethOx *= 0.43734 // Methane when with Oxidizer

TotalOxMeth = #$/TotalLiters$

@TotalOxMeth *= 0.56266 //Oxidizer when with Methane

TotalECconv = 19.35

@TotalECconv *= #$/TotalLiters$

TotalECMass = #$/TotalLiters$ //Value to be used in the tankmass field

@TotalECMass *= 0.0083 //proportional to capacity

TotalECPrice = #$/TotalLiters$ //Same for price, these are the only one I did, my goal was to set up the fuel

@TotalECPrice *= 18.38 //so I might write it later

//to fit all this in FSfuelswitch, since I never got around maths combined with index,

//I wrote all the search nodes on the same line with the punctiation in between.

MODULE

{

name = FSfuelSwitch

resourceNames = Structural;LiquidFuel;LiquidFuel,Oxidizer;LqdMethane,Oxidizer;Karbonite;Water;Ammonia;ElectricCharge;Metal;RocketParts;ScrapMetal;Ore

resourceAmounts = #$/ValueZero$;$/TotalLiters$;$/TotalLiquOx$,$/TotalOxLiqu$;$/TotalMethOx$,$/TotalOxMeth$;$/TotalLiters$;$/TotalLiters$;$/TotalLiters$;$/TotalECconv$;$/LitersRocketPartsMetal$;$/LitersRocketPartsMetal$;$/LitersRocketPartsMetal$;$/LitersOre$;

basePartMass = #$/mass$

tankMass = #$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/TotalECMass$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$

@tankMass += #$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/TotalECMass$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$

tankCost = #$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/TotalECPrice$;$/ValueZero$;$/ValueZero$;$/ValueZero$;$/ValueZero$

displayCurrentTankCost = false

hasGUI = true

availableInFlight = false

availableInEditor = true

showInfo = false

}

!RESOURCE,*{}

//!TotalLiters = null // until now ,if I delete these it's not working anymore but I will see how to get rid of them

//!TotalLiquOx = null

//!TotalOxLiqu = null

//!TotalMethOx = null

//!TotalOxMeth = null

//!ValueZero = null

}

It's reporting a ton of errors when loading, and I think it's because of Nullreferences to stuff that are not in the part (ie maxAmounts of different fuel type ). I could have done it with RESOURCE[*] but I'm having a hard time figuring out how to specify an index, and if it doesnt exist just use zero instead of using the closest match (to add up Oxi and Fuel for multi-fuel tanks, but not add up LiquidFuel twice for regular tanks )

Anyway, I'm not sure it's the appropriate section for a custom cfg, but I post it here anyway because I think it's a excellent case example ( of either what to do or what not to do, sarbian is gonna choose since he understand whats happenning way better than me )

I don't recommend using this cfg right now, it's really just some test string I builded to get to some "How to" of MM

Thanks for the awesome work sarbian, snjo, and Ialdabaoth ( and all the other programmers who are investing some professional level time in our entertainment !!! )

Link to comment
Share on other sites

A selector inside a :HAS[] can look for either a subnode or a value, depending on what punctuation you use. I think the right spelling for your selector is @PART

[*]:HAS[@MODULE[ModuleCommand]:HAS[#minimumCrew[0]]].

You are indeed correct, I ninja edited my post just before you replied, I found that in the probe science cfgs Starwaster has linked in his signature lol, but thank you for the reply :)

I looked around the OP and the documentation wiki but couldn't find anything referring to the # operator, how exactly does it work?

Link to comment
Share on other sites

You are indeed correct, I ninja edited my post just before you replied, I found that in the probe science cfgs Starwaster has linked in his signature lol, but thank you for the reply :)

I looked around the OP and the documentation wiki but couldn't find anything referring to the # operator, how exactly does it work?

It's there on the OP.

It's for fields rather than for nodes so you don't use {} with it.

If a part or a node has a field (variable, property, whatever you think of it as) named x which is set to y then doing :HAS[#x[y]] tests as true.

You'll notice that undercoveryankee's example is :HAS[@MODULE[ModuleCommand]:HAS[#minimumCrew[0]]] ; That :HAS[#minimumCrew[0]] directly after @MODULE[ModuleCommand] so it's checking to see if the MODULE named ModuleCommand has a field named minimumCrew which is set to 0

Link to comment
Share on other sites

Lost all Life Support (TAC) from all stock, B9, Alcor, etc command pods and never had the B9 crew LS on then.

This happens after i put 2.5.3, and when it happens, i try delete the cache, and try revert to 2.5.1 that i use ok all time, but now, still isn't life support at all.

What is happening?

EDIT: Fixed with the MFT config that TAC Life Support release with the package...

Edited by Climberfx
Link to comment
Share on other sites

It's there on the OP.

It's for fields rather than for nodes so you don't use {} with it.

If a part or a node has a field (variable, property, whatever you think of it as) named x which is set to y then doing :HAS[#x[y]] tests as true.

You'll notice that undercoveryankee's example is :HAS[@MODULE[ModuleCommand]:HAS[#minimumCrew[0]]] ; That :HAS[#minimumCrew[0]] directly after @MODULE[ModuleCommand] so it's checking to see if the MODULE named ModuleCommand has a field named minimumCrew which is set to 0

Wow I'm blind or something, I looked and looked and somehow kept missing it but just now saw it :blush:

Yeah I downloaded and looked at the cfgs in your sig right after I posted my first question, and seeing the #vesselType[Probe] part I decided to try the # operator and rewrote my cfg with :HAS[@MODULE[ModuleCommand]:HAS[#minimumCrew[0]] and it accomplished exactly what I was looking for.

Out of curiosity can it be used like :HAS[#X] which will check for field X regardless of the value of X, or would it need to be written :HAS[#X

[*]] or :HAS[#X[]]

Also if you wanted to check if field X is greater than say 2 can you do :HAS[#X[>2]]

Sorry if this is all covered somewhere and I'm just being blind and daft.

Link to comment
Share on other sites

I'm not sure if the greater or equal sign are working, but you could probably do it with :HAS[~X[0],~X[1],~X[2]]

It's working to exclude parts base on their name so it should work for this too

EDIT: in fact it would just select those who don't have these exact values, maybe you can include decimals with a * or something

Edited by Saint-Stanislas
Link to comment
Share on other sites

For some reason module manager has started to semi-consistently freeze at FINAL on the loading screen, with this in player.log:

[ModuleManager] Applying node SXT/SXT_TweakScale/@PART[sXTSaturnV3Upper]:FINAL to SXT/Parts/SaturnV/Stage3Upper/SXTSaturnV3Upper

(Filename: /BuildAgent/work/d63dfc6385190b60/artifacts/LinuxStandalonePlayerGenerated/UnityEngineDebug.cpp Line: 49)

OutOfMemoryException: Out of memory

at (wrapper managed-to-native) string:InternalAllocateStr (int)

at System.String.Concat (System.String str0, System.String str1, System.String str2, System.String str3) [0x00000] in <filename unknown>:0

at ConfigNode.WriteNodeString (System.IO.StreamWriter sw, System.String indent) [0x00000] in <filename unknown>:0

at ConfigNode.WriteNodeString (System.IO.StreamWriter sw, System.String indent) [0x00000] in <filename unknown>:0

at ConfigNode.WriteNodeString (System.IO.StreamWriter sw, System.String indent) [0x00000] in <filename unknown>:0

at ConfigNode.WriteRootNode (System.IO.StreamWriter sw) [0x00000] in <filename unknown>:0

at ConfigNode.WriteNode (System.IO.StreamWriter sw) [0x00000] in <filename unknown>:0

at ConfigNode.Save (System.String fileFullName, System.String header) [0x00000] in <filename unknown>:0

at ConfigNode.Save (System.String fileFullName) [0x00000] in <filename unknown>:0

at ModuleManager.MMPatchLoader.CreateCache () [0x00000] in <filename unknown>:0

at ModuleManager.MMPatchLoader+<ProcessPatch>c__Iterator0.MoveNext () [0x00000] in <filename unknown>:0

(Filename: Line: 4294967295)

I don't understand this as it only happens every 2 out of 3 tries, seems to have something to do with the cache, and I am running KSP on x64 Linux. Even if I were running it on 32 bit, it still never gets above 3 gigs allocated!

I tried deleting most of my mods, which brought the number of loaded patches down from ~5000 to ~3000, but it doesn't seem to have had any effect. I am running MM 2.5.3, and I checked to make sure I only had one MM dll.

Link to comment
Share on other sites

With a large patch count I guess the memory can go a bit high while the cache is created. I'll add a try catch to mitigate the issue, but I m not sure the game can really work well after an OutOfMemoryException.

But why are you using the 32 bit KSP on Linux x64 ? 64bit runs fine on Linux.

Link to comment
Share on other sites

With a large patch count I guess the memory can go a bit high while the cache is created. I'll add a try catch to mitigate the issue, but I m not sure the game can really work well after an OutOfMemoryException.

But why are you using the 32 bit KSP on Linux x64 ? 64bit runs fine on Linux.

I'm not, what I meant was it shouldn't run out of memory even if ​I were running that.

Link to comment
Share on other sites

This was not a explanation, I m just confused that you use 32 bit when you use many mods.

The game runs out of managed memory (the one used by mono) and it's only some part of the KSP memory. I don't know if Unity limits the managed memory size, which may explain the exception.

When I coded the cache I did some test with more than 4k patch without getting this so I don't know why you get it. When it succeed how large is the cache file ?

I'll see if I can code the cache writing differently, but I don't like duplicating things already done in stock KSP code.

Link to comment
Share on other sites

This was not a explanation, I m just confused that you use 32 bit when you use many mods.

The game runs out of managed memory (the one used by mono) and it's only some part of the KSP memory. I don't know if Unity limits the managed memory size, which may explain the exception.

When I coded the cache I did some test with more than 4k patch without getting this so I don't know why you get it. When it succeed how large is the cache file ?

I'll see if I can code the cache writing differently, but I don't like duplicating things already done in stock KSP code.

Now I am confused. I am, or atleast I think I am, running x64 KSP on x64 Linux. That is, I do not use 32 bit. Am I wording this poorly?

Also, the cache size is 2.9 MB (ModuleManager.ConfigCache). Do you need any other information?

Link to comment
Share on other sites

Okay, I am usually quite good at figuring this stuff out without asking for help, but this... I have no clue what is up.

I have three files in which I organize my MM tweaks for my save.

The first one has a bunch of this:

!PART[OMD]:FINAL {}

All of these work.

The second one has a bunch of this:

@PART[sensorAccelerometer]:FINAL
{
@MODULE[ModuleScienceExperiment]
{
@xmitDataScalar = 1.0
}
}

And this:

@EXPERIMENT_DEFINITION[*]:HAS[#id[gravityScan]]:FINAL
{
@baseValue = 18
@scienceCap = 18
@dataScale = 2
}

All of these work.

The third one contains a bunch of this:

@Part[MKS_Antenna]:FINAL
{
@mass = 0.08
}

And this:

@Part[omsEngine]:FINAL
{
@PhysicsSignificance = 0
}

None of them work. Not a single one in the entire file takes.

The file is in the same location as both others. When I load up the game without this file present, the number of "patches applied" does not change, so it feels like MM simpy does not read and process it. And I've been scratching my head over this for hours on end now trying to figure out what is different. I have even created a new file from scratch and typed the code into it by hand (no copy&paste), and it still will not show up ingame or indicate on the loading screen that it is applying more patches.

Is doing this somehow forbidden, or do I need a special format to address those variables? I wouldn't think so, as the very first example code in post two of this thread does exactly what I am doing here, namely modifying a part mass. So, uh. Help?

I'm going to sleep a night over this, but I hope you guys can assist, because I'm all out of ideas.

(This is using version 2.5.3, freshly downloaded just a few moments ago, after having this issue with 2.5.1 and hoping that an update would fix it.)

Link to comment
Share on other sites

Streetwind : You should upload the cfg and log somewhere. I see no reason for it to not be uploaded.

kanelives : it the pass for all the patch without :BEFORE/FOR/AFTER/FINAL. For some mods it's all of them, for other it is nearly none.

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