Jump to content

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


sarbian

Recommended Posts

  • 2 weeks later...

 I am trying to write a simple patch that adjusts engine thrusts based on a formula taking into account their mass, vac isp, and atm isp. I started off with something simple, just trying to replace the thrust with the vacuum ISP then multiply it by a number, but I can't get it to work. Ultimately I would to have [thrust] =[constant] x [isp atm] + [constant] x [isp vac] + [constant ] * mass] or something like this. Below is what I have so far but it does not really seem to do anything. Any help would be super appreciated!

@PART[*]:HAS[@MODULE[ModuleEngines*]]:FINAL
{
    @MODULE[ModuleEngines*]
    {
 
        @maxThrust = #$/atmosphereCurve/key,0[1,]$
        @maxThrust *= 2
    }
}

    Edit: I was able to solve my own problem. I fit a trend line to a list of real rockets and found a thrust (N) ~ (-3 * ISP (seconds) + 1850) * mass (kg). I had to scale it down to be balance for KSP so I added a final multiplier to balance.

 

@PART[*]:HAS[@MODULE[ModuleEngines*]]:FINAL
{
    @MODULE[ModuleEngines*]
    {
		@maxThrust = #$/MODULE[ModuleEngines*]/atmosphereCurve/key,0[1, ]$
		@maxThrust *= -3
		@maxThrust += 1850
		@maxThrust *= #$../mass$
		@maxThrust *= 0.24
    }
} 	

 

Edited by tlion
Link to comment
Share on other sites

  • 3 weeks later...

How can I use a variable inside a curve key?

I tried the following:

atmosphereCurve
{
    key = 0 #$../../../../../origIspVac$ * 2.56
    key = 1 186
}

But the value does not get computed. Checking on MuduleManager.ConfigCache it looks exactly so, when it should have the value attributed to that variable (the relative path seems to be correct)

This is the complete patch:

Spoiler
@PART[*]:HAS[@MODULE[ModuleEngines]]
{
        origIspVac = #$/MODULE[ModuleEngines]/atmosphereCurve/key,0[1, ]$
        origIspSL = #$/MODULE[ModuleEngines]/atmosphereCurve/key,1[1, ]$
 
        MODULE
        {
                name = ModuleB9PartSwitch
                moduleID = rssSurealismFuelMixture
                switcherDescription = Fuel mixture
                switcherDescriptionPlural = Fuel mixtures
                affectDragCubes = false
                affectFARVoxels = false
                switchInFlight = false
                advancedTweakablesOnly = false
                uiGroupName = rssSurealismFuelMixtures
                uiGroupDisplayName = Fuel mixtures
 
                SUBTYPE
                {
                        name = Monopropellant
                        title = Monopropellant
                        addedMass = 0
                        addedCost = 0
 
                        MODULE
                        {
                                IDENTIFIER
                                {
                                        name = ModuleEngines
                                }
                                DATA
                                {
                                        PROPELLANT{}
                                        PROPELLANT{}
                                        PROPELLANT
                                        {
                                                name = Monopropellant
                                                ratio = 1
                                                DrawGauge = True
                                        }
                                        atmosphereCurve
                                        {
                                                key = 0 #$../../../../../origIspVac$ * 2.56
                                                key = 1 186
                                        }
                                }
                        }
                }
        }
}

 

Edited by mateusviccari
Link to comment
Share on other sites

11 hours ago, Gordon Dry said:

@mateusviccari is origIspVac on the root node? Yes.

Then try #$/origIspVac$

Well that's a million times better, but still not the culprit. I just found out that I can't type a variable after the "0 ". If I put the variable by itself, after the "=" it works. Guess I'll just have to find how to concatenate the fixed number with the variable.

Link to comment
Share on other sites

10 minutes ago, Gordon Dry said:

Oh well, it's kinda text string, so you need RegEx voodoo. But don't ask me, I was just coming back from hiatus a week ago ...

Never mind, I did it by applying more patches, here's the solution if it comes in handy for future passersby:

Spoiler

@PART[*]:HAS[@MODULE[ModuleEngines]]
{
    origIspVac = #$/MODULE[ModuleEngines]/atmosphereCurve/key,0[1, ]$
    origIspSL = #$/MODULE[ModuleEngines]/atmosphereCurve/key,1[1, ]$

    MODULE
    {
        name = ModuleB9PartSwitch
        moduleID = rssSurealismFuelMixture
        switcherDescription = Fuel mixture
        switcherDescriptionPlural = Fuel mixtures
        affectDragCubes = false
        affectFARVoxels = false
        switchInFlight = false
        advancedTweakablesOnly = false
        uiGroupName = rssSurealismFuelMixtures
        uiGroupDisplayName = Fuel mixtures

        SUBTYPE
        {
            name = RP1_LOX
            title = RP1+LOX
            addedMass = 0
            addedCost = 0

            MODULE
            {
                IDENTIFIER
                {
                    name = ModuleEngines
                }
                DATA
                {
                    PROPELLANT{}
                    PROPELLANT{}
                    PROPELLANT
                    {
                        name = Kerosene
                        ratio = 0.4
                        DrawGauge = True
                    }
                    PROPELLANT
                    {
                        name = LqdOxygen
                        ratio = 0.6
                    }
                    atmosphereCurve
                    {
                        key = 0 6662 //Placeholder, will be changed later
                        key = 1 6661 //Placeholder, will be changed later
                    }
                }
            }
        }

        SUBTYPE
        {
            name = Monopropellant
            title = Monopropellant
            addedMass = 0
            addedCost = 0

            MODULE
            {
                IDENTIFIER
                {
                    name = ModuleEngines
                }
                DATA
                {
                    PROPELLANT{}
                    PROPELLANT{}
                    PROPELLANT
                    {
                        name = Monopropellant
                        ratio = 1
                        DrawGauge = True
                    }
                    atmosphereCurve
                    {
                        key = 0 6662 //Placeholder, will be changed later
                        key = 1 6661 //Placeholder, will be changed later
                    }
                }
            }
        }
    }
}

//Applies the original engine ISP
@PART[*]:HAS[@MODULE[ModuleEngines]] {
    @MODULE[ModuleB9PartSwitch] {
        @SUBTYPE[*],* {
            @MODULE,0 {
                @DATA,1 {
                    @atmosphereCurve {
                        @key,0[1, ] = #$/origIspVac$
                        @key,1[1, ] = #$/origIspSL$
                    }
                }
            }
        }
    }
}

//Multiplies the engine ISP to make them usable in RSS
@PART[*]:HAS[@MODULE[ModuleEngines]] {
    @MODULE[ModuleB9PartSwitch] {
        @SUBTYPE[Monopropellant] {
            @MODULE,0 {
                @DATA,1 {
                    @atmosphereCurve {
                        @key,0[1, ] *= 2.0
                        @key,1[1, ] *= 2.0
                    }
                }
            }
        }

        @SUBTYPE[RP1_LOX] {
            @MODULE,0 {
                @DATA,1 {
                    @atmosphereCurve {
                        @key,0[1, ] *= 2.3
                        @key,1[1, ] *= 2.3
                    }
                }
            }
        }
    }
}

 

Link to comment
Share on other sites

  • 2 weeks later...

How do I target a part with a module X and without a module Y?

I'm trying to target all engines except the RAPIER engine. I tried:

@PART[*]:HAS[@MODULE[ModuleEngines*]]:HAS[!MODULE[MultiModeEngine]]

But no matter where I put the exclamation mark, it never works, since it always targets the rapier engine regardless. What am I doing wrong?

EDIT: Forget I asked, turns out we can only have one HAS in the filter, and this is how it should be done:

@PART[*]:HAS[@MODULE[ModuleEngines*],!MODULE[MultiModeEngine]]

Edited by mateusviccari
Link to comment
Share on other sites

  • 2 weeks later...
  • 4 weeks later...
3 minutes ago, modus said:

Maybe you should ask this in the FTT thread? But:

I don't think those containers are from FTT, they're from MKS. Do you have that installed?

What version of FTT/MKS (or any other usi mod) do you use? What ksp version?

 

Yeah, i had both tabs open and posted in the wrong one... Using the entire latest constellation with everything. UmbraSpaceIndustries_112.0.1-bleeding-edge.2 / ksp 1.12.3
i went and posted in the Umbra thread already. Thanks.

Link to comment
Share on other sites

I'm having trouble understanding the syntax in a few module manager patches I've seen. Can anyone explain what these three (unrelated) examples do? Number 3, in particular, is a complete enigma to me.

1	@PitchTorque *= #$/mass$
2	@description ^= :Unpressurized::
3	@title ^= :(.)$:$0 (UNPRESSURIZED) :

 

Link to comment
Share on other sites

On 11/30/2021 at 5:10 PM, zer0Kerbal said:

how does one escape a # character?

I want to replace a localization string using a patch; MM finds the string, but when putting it back it leaves the '#' off.

If the strings are parsed as HTML then &35; or even # might, possibly work.

Link to comment
Share on other sites

15 hours ago, Kwebib said:

I'm having trouble understanding the syntax in a few module manager patches I've seen. Can anyone explain what these three (unrelated) examples do? Number 3, in particular, is a complete enigma to me.

1	@PitchTorque *= #$/mass$
2	@description ^= :Unpressurized::
3	@title ^= :(.)$:$0 (UNPRESSURIZED) :

 

  1. multiplies PitchTorque * mass of same part
  2. inserts "Unpressurized:" at the start of the part description
  3. same as #2, but uses a ReEx (Regular Expression) to place the insertion

https://github.com/sarbian/ModuleManager/wiki/Module-Manager-Syntax

Link to comment
Share on other sites

I'm getting a warning from modulemanager (during the loading screen), caused by one of my configs. I'm pretty new to MM patching, and after some looking around, I still can't seem to find where that warning is logged. (perhaps it isn't?) Is there a file somewhere where it says what that warning was about exactly?

If it helps, this is the MM patch that caused it, but I don't know why this code would be problematic:
(although I do know it is likely caused by the first line)

Spoiler

@PART[nuclearEngine]:NEEDS[B9PartSwitch&Waterfall&StockWaterfallEffects&Upsilon]:FOR[Upsilon]:AFTER[StockWaterfallEffects]
{
  MODULE
  {
      name = ModuleB9PartSwitch
    moduleID = plumeSwitch
    switcherDescription = Plume
    switcherDescriptionPlural = Plumes
    affectDragCubes = false
    affectFARVoxels = false
    switchInFlight = true
    
    SUBTYPE
    { 
        name = default
        title = Nerv plume
    }
    SUBTYPE
    {
        name = hermes1
        title = hermes hydrogen antimatter plume
        MODULE
        {
            IDENTIFIER { name = ModuleWaterfallFX }
            DATA
            {
                TEMPLATE
                {
                    name = plume
                    templateName = upsilon-hermes-hydrogen-antimatter
                    scale = 1,1,1
                    rotation = 0,0,0
                    position = 0,0.0,0
                }
                TEMPLATE
                {
                    name = core
                    templateName = upsilon-empty
                    scale = 1,1,1
                    rotation = 0,0,0
                    position = 0,0.0,0
                }
            }
        }
    }
    SUBTYPE
    {
        name = empty
        title = empty
        MODULE
        {
            IDENTIFIER { name = ModuleWaterfallFX }
            DATA
            {
                TEMPLATE
                {
                    name = plume
                    templateName = upsilon-empty
                    scale = 1,1,1
                    rotation = 0,0,0
                    position = 0,0.0,0
                }
                TEMPLATE
                {
                    name = core
                    templateName = upsilon-empty
                    scale = 1,1,1
                    rotation = 0,0,0
                    position = 0,0.0,0
                }
            }
        }
    }
  }
}

 

Link to comment
Share on other sites

10 minutes ago, Knight of St John said:

I'm getting a warning from modulemanager (during the loading screen), caused by one of my configs. I'm pretty new to MM patching, and after some looking around, I still can't seem to find where that warning is logged. (perhaps it isn't?) Is there a file somewhere where it says what that warning was about exactly?

You should provide all your logs to help in troubleshooting this issue.

 

10 minutes ago, Knight of St John said:

If it helps, this is the MM patch that caused it, but I don't know why this code would be problematic:
(although I do know it is likely caused by the first line)

Quote

@PART[nuclearEngine]:NEEDS[B9PartSwitch&Waterfall&StockWaterfallEffects&Upsilon]:FOR[Upsilon]:AFTER[StockWaterfallEffects]

I'm a bit rusty on MM configs, but one problem I'm sure of--though I don't think it's the cause of your issue--is that "Upsilon" should not be in both NEEDS and FOR.

FOR means this MM config is part of mod "Upsilon".  NEEDS means that this MM config isn't part of any of the mods listed, but needs those mods to work properly.  Only one of these is true.

Edited by Jacke
Link to comment
Share on other sites

How can I edit the wasteheat storage amount? For example, I want to increase the maximum storage of wasteheat of heatfin to 1000000. I tried to create a MyPatches.cfg under GameData. Here is what I did:

@PART[heatfin2]
{
    @RESOURCE[WasteHeat]
    {
        @amount *= 400
        @maxAmount *= 400
    }
}

 

In VAB and SPH it appears that this editing is effective because the statistic displayed is changed. But once I hit launch and right click the heatfin, the maximum wasteheat is still not changed. This is very puzzling to me. Can someone help?

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