sarbian

[1.4.0-1.7.x] Module Manager 4.0.3 (August 9th 2019) - Right To Ludicrous Speed

Recommended Posts

Hi folks. I am looking for some guidance with how to handle variables.

I have this patch;

Spoiler

// ----------------------------------------------------------- MM Patched Here ----------------------------------------------------------------------------------------------

// This patch adds changes the rate at which a liquid turns into a gas in IFS Cryogenic Tanks
//        needs to run after InterstellarFuelSwitch as it alters parts created by it
//        InterstellarFuelSwitch runs at some point

@PART[CT250?]:HAS[@MODULE[InterstellarResourceConverter]]:NEEDS[InterstellarFuelSwitch]:AFTER[WildBlueTools]
{
    @MODULE[InterstellarResourceConverter]:HAS[#primaryResourceNames[LqdXenon]]
    {
        %MYMMmaxPowerMul = 1000        // create variable my_mm maxPower Multiplier 1.0 = same as stock IFS

        @maxPowerPrimary *= #$MYMMmaxPowerMul$
        @maxPowerSecondary *= #$MYMMmaxPowerMul$
    }
}
@PART[CT250?]:HAS[@MODULE[InterstellarResourceConverter]]:NEEDS[InterstellarFuelSwitch]:AFTER[WildBlueTools]
{
    @MODULE[InterstellarResourceConverter]:HAS[#primaryResourceNames[LqdXenon]]
    {
        !MYMMmaxPowerMul            // delete variable
    }
}


// ----------------------------------------------------------- Just Notes Below Here ----------------------------------------------------------------------------------------
// Notes    MODULE
// Notes        {
// Notes            name = InterstellarResourceConverter
// Notes            primaryResourceNames = LqdXenon
// Notes            secondaryResourceNames = XenonGas
// Notes            maxPowerPrimary = 10
// Notes            maxPowerSecondary = 10
// Notes            primaryConversionEnergyCost = 95.586
// Notes            secondaryConversionEnergyCost = 17.2958 // 108.099 * 0.16
// Notes        }
// Notes
// Notes    :FINAL is a cop out and should be avoided if possible
// Notes    :AFTER[InterstellarFuelSwitch] ? Do we need to wait for anything else to act upon IFS before this patch?
// Notes    :AFTER[WildBlueTools] Assuming any WBI mod is installed, WildBlueTools is processed near the end of the mod processing list

The present problem is that MYMMmaxPowerMul is present in ModuleManager.ConfigCache

I am wondering why that is?

Another question is, if I move the creation of MYMMmaxPowerMul up one node, like;

Spoiler

@PART[CT250?]:HAS[@MODULE[InterstellarResourceConverter]]:NEEDS[InterstellarFuelSwitch]:AFTER[WildBlueTools]

{

    %MYMMmaxPowerMul = 1000        // create variable my_mm maxPower Multiplier 1.0 = same as stock IFS

    @MODULE[InterstellarResourceConverter]:HAS[#primaryResourceNames[LqdXenon]]
    {
        @maxPowerPrimary *= #$MYMMmaxPowerMul$
        @maxPowerSecondary *= #$MYMMmaxPowerMul$
    }
}
@PART[CT250?]:HAS[@MODULE[InterstellarResourceConverter]]:NEEDS[InterstellarFuelSwitch]:AFTER[WildBlueTools]
{
        !MYMMmaxPowerMul            // delete variable
}

Would creating MYMMmaxPowerMul in such a place allow the variable to be used in the sub node? Or is it bound into the node level it was created in?

I am considering moving the variable to such a place, because I may wish to use the conversion factor for more that just XenonGas. This is not critical for the moment and I am quite happy to expand out the code on a case by case basis for any additional gas conversion rates that I wish to change.

I want to avoid using :FINAL as a means of forcing the deletion, is :FINAL the only way to ensure the variable is removed.

Does anyone have some helpful comments that can share?

 

Share this post


Link to post
Share on other sites

@Apaseall

1.  !MYMMmaxPowerMul  = delete

2. @maxPowerPrimary *= #$/MYMMmaxPowerMul$

^ #$/  <- the / makes MM search in the root

Share this post


Link to post
Share on other sites

Hi all, I had a question about the "volume" parameter for RESOURCE_DEFINITION. What does this actually affect? I've tried changing it but I don't see anything changing in-game.

Share this post


Link to post
Share on other sites
1 hour ago, Siconix said:

Hi all, I had a question about the "volume" parameter for RESOURCE_DEFINITION. What does this actually affect? I've tried changing it but I don't see anything changing in-game.

It's used by mods but not by stock. It was added to the stock class for modders to use

Share this post


Link to post
Share on other sites

@blowfish How do I calculate a square root?

 

Edit:

Now I have a really weird issue - there is no MM error, but a variable is calculated to "Infinity" for whatever reason.
This occurs to all parts this patch was tinkering with.
I have the intuition that it could be there are too many decimal digits?
But how to decrease the amount of digits, is there a math.round in MM to limit the amount of decimal digits?

This is the calculation:

			tempdeploy = #$/MODULE[ModuleParachute]/semiDeployedDrag$
			@tempdeploy /= #$/MODULE[ModuleParachute]/stowedDrag$
			@tempdeploy *= 9.8696044010893586188344909998762
			preDeployedDiameter = #$tempdeploy$
			@preDeployedDiameter *= #$/mass$

Using the values of a specific reference part the result should be 0.62723495983369873586332051204075
But in ModuleManager.ConfigCache it says

				preDeployedDiameter = Infinity

Fun fact is, the calculation part right after that works:

			@tempdeploy = #$/MODULE[ModuleParachute]/fullyDeployedDrag$
			@tempdeploy /= #$/MODULE[ModuleParachute]/semiDeployedDrag$
			@tempdeploy *= 9.8696044010893586188344909998762
			deployedDiameter = #$tempdeploy$
			@deployedDiameter *= #$/mass$

Using the same reference part the calculation gives the correct result of

				deployedDiameter = 68.9958455816896

 

Edited by Gordon Dry

Share this post


Link to post
Share on other sites

@blowfish Can I cut a substring, like make the value of a variable only have 2 decimal digits?
before: 1.58614853107489
after: 1.58

At least this would be very helpful.

Share this post


Link to post
Share on other sites

@Gordon Dry not sure about the Infinity issue, can you by chance edit it to output all the intermediate values as well?  That would help in figuring out where something is going wrong.

You can truncate with regex replacement.  I think you want something like @value ^= :(\.\d\d)\d+$:$1:

How does this work?  You're matching a period followed by two decimals, followed by one or more decimals, followed by the end of the string, and replacing it with the part you're capturing (the period and two decimals)

Disclaimer: I haven't tried this

Edited by blowfish

Share this post


Link to post
Share on other sites

Hello folks. I am failing to change the model for a part I created by cloning.

The original:

Spoiler

    MODEL
    {
        model = blah
    }

My patch:

Spoiler

    @MODULE[MODEL]
    {
        @model = foo
    }

I would like to edit rather than delete and create a new ie I do not want to do this:

Spoiler

-MODULE[MODEL] {}
MODULE
{
model = foo
}

Am I missing something simple?

I have the same problem when I try:

Spoiler

    @MODULE[INTERNAL]
    {
        @name = bar
    }

 

The other keys I seem to be able to edit with success, and delete those I do not want/need, be they under PART or in a MODULE. Just the model and INTERNAL that I fail with. There are no errors btw. But examining ModuleManager.ConfigCache I see the results.

Share this post


Link to post
Share on other sites

@Apaseall there is no MODULE involved, so there should not be anything called that in your patch.  If you want to edit the model node, it's @MODEL { }

Share this post


Link to post
Share on other sites

Is it possible to edit certain module key values via percentage? example would be editing any part with an engine module to increase/decrease max thrust by x%, or resource requirements, resource outputs for converters, EC generation, etc.

or is that more of a plugin thing?

Share this post


Link to post
Share on other sites

Can someone help ive been looking for a download button or link or something but cant find one and I need it for the KIS mod and dont anything on all this... math... tech... stuff yall are putting out there im just a sophomore

 

 

never mind found it

Edited by Killer_Garfin

Share this post


Link to post
Share on other sites

looking at the order patches run in.  I understand that they run in an alphabetical order, so naming can change the order of patches.  What is the sort order used for this?  as in, I see putting things like special characters or numbers can move something up in the list.  but what about moving things down?  what is the last character in the sort order?  anything beyond "z"?

Share this post


Link to post
Share on other sites
12 minutes ago, Bit Fiddler said:

looking at the order patches run in.  I understand that they run in an alphabetical order, so naming can change the order of patches.  What is the sort order used for this?  as in, I see putting things like special characters or numbers can move something up in the list.  but what about moving things down?  what is the last character in the sort order?  anything beyond "z"?

Look at the ascii character set

Share this post


Link to post
Share on other sites
11 minutes ago, Bit Fiddler said:

looking at the order patches run in.  I understand that they run in an alphabetical order, so naming can change the order of patches.  What is the sort order used for this?  as in, I see putting things like special characters or numbers can move something up in the list.  but what about moving things down?  what is the last character in the sort order?  anything beyond "z"?

It's however KSP decides they should be sorted (ModuleManager doesn't do this explicitly).  Probably ends up being whatever order things are in when each directory is listed.  You can check the log to see what order things ended up in.

In general though I'd say it's best not to depend on alphabetical order within a particular pass.  If you need patch X to run before patch Y, put them in different passes.

Share this post


Link to post
Share on other sites

Hello all.

A quick question. I am trying to give a part from the Making history expansion a new place in the tech tree. Now all other parts go to their new place in the tech tree. But not that one part from Making History. See the cfg file:

 

@PART[parachuteSingle]:FINAL
{
	@TechRequired = startx
}
@PART[trussPiece1x]:FINAL
{
	@TechRequired = startx
}
@PART[kv1Pod]:FINAL
{
	@Techrequired = startx
}

It is the kv1Pod (that's the name of the config file). It simply wont move to it's new place. All other non Making History parts DO move (there are many more parts I moved around then the ones in the example. Is there some extra thing needed to make it move? I tried different versions for the partname and none worked (KV1Pod, Kv1Pod and kv1Pod).

Regards for any answer

Share this post


Link to post
Share on other sites
5 hours ago, waerth said:

Hello all.

A quick question. I am trying to give a part from the Making history expansion a new place in the tech tree. Now all other parts go to their new place in the tech tree. But not that one part from Making History. See the cfg file:

 


@PART[parachuteSingle]:FINAL
{
	@TechRequired = startx
}
@PART[trussPiece1x]:FINAL
{
	@TechRequired = startx
}
@PART[kv1Pod]:FINAL
{
	@Techrequired = startx
}

It is the kv1Pod (that's the name of the config file). It simply wont move to it's new place. All other non Making History parts DO move (there are many more parts I moved around then the ones in the example. Is there some extra thing needed to make it move? I tried different versions for the partname and none worked (KV1Pod, Kv1Pod and kv1Pod).

Regards for any answer

Your TechRequired has a baby r, but it needs a big R.

Share this post


Link to post
Share on other sites
Quote

Your TechRequired has a baby r, but it needs a big R.

Thank you thank you thank you!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Share this post


Link to post
Share on other sites

Is there a syntax to prevent patches from being applied to a mod without modifying each foreign mod? I'm looking at the KOOSE pods and it's silly the number of toggles that are in the right click menu of the parts. I'm running about 70 mods and a good number of these are applying patches to the KOOSE parts that aren't really relevant to an escape pod. I'd like to be able to put together a patch in the KOOSE mod to tell other mods to skip it. The best I can come up with is deleting modules after they've been applied as part of a set of :FINAL patches in my personal mods.

Edited by Tonka Crash

Share this post


Link to post
Share on other sites
40 minutes ago, Tonka Crash said:

Is there a syntax to prevent patches from being applied to a mod without modifying each foreign mod? I'm looking at the KOOSE pods and it's silly the number of toggles that are in the right click menu of the parts. I'm running about 70 mods and a good number of these are applying patches to the KOOSE parts that aren't really relevant to an escape pod. I'd like to be able to put together a patch in the KOOSE mod to tell other mods to skip it. The best I can come up with is deleting modules after they've been applied as part of a set of :FINAL patches in my personal mods.

Your solution is probably the best way. 

Otherwise there is this, although I haven't tried it in 1.4.5

 

Share this post


Link to post
Share on other sites

I've been trying to modify the afterburning jet to use a new resource, but I can't figure out how to get both ModuleEngineFX modules. I've managed to get one of them with this, but not both.

@PART[turboJet]:FINAL
{
	@MODULE[ModuleEnginesFX]
	{
		@PROPELLANT[LiquidFuel]
		{
			@name = AP1
		}
	}
}

 

Share this post


Link to post
Share on other sites
15 minutes ago, FungusForge said:

I've been trying to modify the afterburning jet to use a new resource, but I can't figure out how to get both ModuleEngineFX modules. I've managed to get one of them with this, but not both.

Try this:

@PART[turboJet]:FINAL
{
	@MODULE[ModuleEnginesFX],*
	{
		@PROPELLANT[LiquidFuel]
		{
			@name = AP1
		}
	}
}

By adding the  ,*  , you will adress every module with the same name. You can also use numbers to adress them separately, i.e. @MODULE[ModuleEnginesFX],0 for the first module, and @MODULE[ModuleEnginesFX],1 for the second.

Edited by 4x4cheesecake

Share this post


Link to post
Share on other sites
35 minutes ago, 4x4cheesecake said:

By adding the  ,*  , you will adress every module with the same name. You can also use numbers to adress them separately, i.e. @MODULE[ModuleEnginesFX],0 for the first module, and @MODULE[ModuleEnginesFX],1 for the second.

Thank you!

Share this post


Link to post
Share on other sites

There is this MM issue with CC / Kerbalism again, since I use KSP 1.4.5:

@JH4C says

Quote

That filepath would appear to suggest the issue occurs while MM is processing a file supplied by Kerbalism; it's certainly not a file that's included in CC, and I don't have that error when I load my game (which does not include Kerbalism.) As such, you might have better luck asking in the Kerbalism thread.

@PiezPiedPy says:

Quote

its not a CC error as CC is not referenced in that exception. Could be an MM issue

 

I'm not sure where to start to eliminate this issue ...

Share this post


Link to post
Share on other sites
4 hours ago, Gordon Dry said:

I'm not sure where to start to eliminate this issue ...

I just posted a reply in the CC topic to what I think it might be.

 

Share this post


Link to post
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.