Jump to content

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


sarbian

Recommended Posts

This is probably a quick question, but I can't find the syntax so looking for help.

I have a quick patch to add the 1.11 ModuleInventoryPart to any parts that currently have ModuleKISInventory and what I'd like to do is read the number of slots in the KIS version (which is x by y rows) and use math to add the same total number of Stock Slots to that part. Also do the same thing for Volume.  Pointers to sample code appreciated!

@PART[*]:HAS[@MODULE[ModuleKISInventory],!MODULE[ModuleInventoryPart]]
{
    MODULE
    {
        name = ModuleInventoryPart
        InventorySlots = #$../MODULE[ModuleKISInventory]/slotsX$
        @InventorySlots *= #$../MODULE[ModuleKISInventory]/slotsY$
        packedVolumeLimit = #$../MODULE[ModuleKISInventory]/maxVolume$ 
    }
    
}

Link to comment
Share on other sites

On 12/19/2020 at 3:30 PM, Atlas Gaming said:

This is probably a quick question, but I can't find the syntax so looking for help.

I have a quick patch to add the 1.11 ModuleInventoryPart to any parts that currently have ModuleKISInventory and what I'd like to do is read the number of slots in the KIS version (which is x by y rows) and use math to add the same total number of Stock Slots to that part. Also do the same thing for Volume.  Pointers to sample code appreciated!


@PART[*]:HAS[@MODULE[ModuleKISInventory],!MODULE[ModuleInventoryPart]]
{
    MODULE
    {
        name = ModuleInventoryPart
        InventorySlots = #$../MODULE[ModuleKISInventory]/slotsX$
        @InventorySlots *= #$../MODULE[ModuleKISInventory]/slotsY$
        packedVolumeLimit = #$../MODULE[ModuleKISInventory]/maxVolume$ 
    }
}

 

This all looks correct to me, what in particular isn't working about it?

p.s. code blocks make it a lot easier to read

Link to comment
Share on other sites

Have I got this syntax correct with the nested HAS commands? I'm trying to write a patch for all crewable parts that have a science container - ie specifically not including the external command chair as it doesn't have a ScienceContainer. Wrote this looking at the wiki and think I've got it right, but thought it worth checking.

@PART[*]:HAS[    @MODULE[ModuleCommand],#CrewCapacity[>1]   :HAS[  @MODULE[ScienceContainer]    ]          ] {}

Link to comment
Share on other sites

Hey I'm looking for a couple commands and not finding them in this forum...

First is there an If () {} type command to test conditions before applying a patch?

Second is there a round or ToInteger command?

Or a Div function... or really a list of all the math functions included?

 

Edited by Atlas Gaming
Link to comment
Share on other sites

@Atlas Gaming, I am usually able to use :HAS[] in combination with NEEDS as the basis to apply a patch.  Do you have anything in particular?

I do not know about rounding, but I have found this really clever way to get an integer that is functionally a floor function using regular expressions in Kerbalism.  Think it works through just truncating anything after the point.

@rated_ignitions ^= :\.\d+:: // Floor value to get an integer

@cyberKerb, think it should be as I don't think the > implies greater than or equal

@PART[*]:HAS[@MODULE[ModuleCommand],#CrewCapacity[>0],@MODULE[ModuleScienceContainer]] {}

 

Link to comment
Share on other sites

Just now, hemeac said:

@cyberKerb, think it should be as I don't think the > implies greater than or equal


@PART[*]:HAS[@MODULE[ModuleCommand],#CrewCapacity[>0],@MODULE[ModuleScienceContainer]] {}

 

Oops - yep - you're right about that. Thanks for the catch! I'm guessing I got the brackets correct then cheers :) 

Link to comment
Share on other sites

Example would be calculating the number of crew spots in a capsule based on volume.

Volume of 3.4m/crew for instance... so total volume would be a decimal, and I'd want to round it down to an integer after doing the division to see how many crew it could support. (ignore seats and stuff for now)

  This may do it... never though to use RE

9 minutes ago, hemeac said:

@rated_ignitions ^= :\.\d+:: // Floor value to get an integer

 

Edited by Atlas Gaming
Link to comment
Share on other sites

7 minutes ago, Atlas Gaming said:

Example would be calculating the number of crew spots in a capsule based on volume.

Volume of 3.4m/crew for instance... so total volume would be a decimal, and I'd want to round it down to an integer after doing the division to see how many crew it could support. (ignore seats and stuff for now)

  This may do it... never though to use RE

 

@Atlas Gaming I came across it randomly, has been really handy for displaying thrust and ISP statistics in descriptions after altering them with multipliers.  There's some other good bits in the code that may come in handy:
 

https://raw.githubusercontent.com/Kerbalism/Kerbalism/master/GameData/KerbalismConfig/System/Reliability.cfg

Link to comment
Share on other sites

In case it helps: this mod seems to work OK for me in KSP 1.11

I've briefly tested it, with the following list of things installed:

KSP 1.11.0.3045 win x64 (Steam)
Making History 1.11.0
Breaking Ground 1.6.0

Chatterer v0.9.99 - Keep talking!
Click Through Blocker 0.1.10.14
Docking Sounds!! 2.1.12.27690 (10/7/16)
E.V.E. Redux 1.11.1.1 (from blackrack) + Configs-1.2.2.1 (from WazWaz)
Final Frontier 1.10.0-3485 + KerbFleet Custom Ribbons 1.2.0
Kerbal Alarm Clock 3.13.0.0
Module Manager 4.1.4
PlanetShine v0.2.6.2 Oct 19, 2019
Rover Wheel Sounds (Revived) v1.8.1.11.20.19 (from DoctorDavinci, .dll overwritten with the one from MAFman)
Scatterer - atmospheric scattering 0.0722
Texture Replacer 4.3
ToolbarController 0.1.9.4
[x] Science! v5.26

Also, thank you very much to the developer(s) of this mod!

Link to comment
Share on other sites

In another thread, @Sovetskysoyuz noticed that a  patch that I posted (as a workaround on the bug-tracker) using Module Manager 4.1.4 at risk with the new KSP 1.11.0,
did not have effect when he loaded KSP, even though it worked for me when I tested it by re-running Module Manager through alt-F11 :

@PHYSICSGLOBALS {
    @partRBMassMin = 0.005  // no effect on initial load of KSP, but takes effect upon alt-F11 reload
    @dragMultiplier = 0     // always works
    @liftMultiplier = 0     // always works
}

From the log, it appears the Module Manager applies the patch without errors.  And all changed entries appear in 'ModuleManager.Physics' and 'ModuleManager.ConfigCache'

[LOG 18:16:08.271] :LEGACY (default) pass
[LOG 18:16:08.275] Applying update /mass/@PHYSICSGLOBALS to /Physics.cfg/PHYSICSGLOBALS

Maybe the new parameter  'partRBMassMin' is read at a different time than the other variables are read from 'Physics.cfg'

Edited by OHara
repair link
Link to comment
Share on other sites

Has anyone produced a patch to reduce fuel tank max temperature but exclude spaceplane parts MK2 and MK3?

EDIT:  This works.

@PART[*]:HAS[#category[FuelTank]]:Final
{
	@maxTemp = 1200
}
@PART[Size3*,externalTankRound,externalTankCapsule,bluedog_DeltaIV_DCSS_5m,bluedog_DCSS_Tank]:Final
{
	@maxTemp = 1200
}
@PART[mk3Fuselage*,adapterMk3*,adapterSize3*,adapterSize2-Mk2]:Final
{
	@maxTemp = 2700
}

 

Edited by NyanTurian
solution found
Link to comment
Share on other sites

On 12/29/2020 at 10:29 AM, OHara said:

Maybe the new parameter  'partRBMassMin' is read at a different time than the other variables are read from 'Physics.cfg'

Ugh, I'll look, if KSP is accessing this before MM has a chance to do its thing then there might not be anything to be done, but maybe it can be set later too.

E: hmm, not seeing anything obviously different here, can you provide more info about what about it doesn't seem to be getting picked up?

Edited by blowfish
Link to comment
Share on other sites

On 1/2/2021 at 8:28 AM, blowfish said:

can you provide more info, about what about it, doesn't seem to be getting picked up?

For the the bug-report I made the simplest craft (link) that I could think of, to show the problem when this new 'partRBMassMin'  has its large default value.   To test if a MM patch to reduce partRMBassMin has the desired effect, one has to load that craft and see which direction it tips over.

Now I notice that even the alt-F11 reload does not always have the effect on the craft -- the first alt-F11 reload after starting KSP takes effect, but then I cannot reverse the change in a further alt-F11 reload.

If I use the alt-F12 menu to write ModuleManager.Physics, the file produced always shows a value for 'partRBMassMin' matching the most recently loaded cfg file.  But if I load a craft and test, the behavior often does not match that expected from the recently loaded cfg.   

I have no reason to expect that modders will want to adjust partRBMassMin.   (I hope Squad will remove this parameter in the course of resolving the reported bug).  The only reason I used a MM patch was to post workaround for the bug, safer than editing Physics.cfg directly.

Link to comment
Share on other sites

On 1/3/2021 at 4:58 PM, OHara said:

For the the bug-report I made the simplest craft (link) that I could think of, to show the problem when this new 'partRBMassMin'  has its large default value.   To test if a MM patch to reduce partRMBassMin has the desired effect, one has to load that craft and see which direction it tips over.

Now I notice that even the alt-F11 reload does not always have the effect on the craft -- the first alt-F11 reload after starting KSP takes effect, but then I cannot reverse the change in a further alt-F11 reload.

If I use the alt-F12 menu to write ModuleManager.Physics, the file produced always shows a value for 'partRBMassMin' matching the most recently loaded cfg file.  But if I load a craft and test, the behavior often does not match that expected from the recently loaded cfg.   

I have no reason to expect that modders will want to adjust partRBMassMin.   (I hope Squad will remove this parameter in the course of resolving the reported bug).  The only reason I used a MM patch was to post workaround for the bug, safer than editing Physics.cfg directly.

Okay I figured out what's happening - MM is delaying replacing physics until the space center, which means that when the part loader reads those values it gets the stock ones.  If you reload the game database it might get the values from the first load.  I can't see any reason why MM shoudln't be able to do the physics thing immediately, so the solution is probably just to do that.

Link to comment
Share on other sites

5 hours ago, blowfish said:

Okay I figured out what's happening - MM is delaying replacing physics until the space center, which means that when the part loader reads those values it gets the stock ones.  If you reload the game database it might get the values from the first load.  I can't see any reason why MM shoudln't be able to do the physics thing immediately, so the solution is probably just to do that.

Please check if it would not break TechTree first.  [There should be a reason for the Physics Database and the TechTree being loaded (and reloaded) every time you enter in the Space Centre scene]

Edited by Lisias
post edit (in brackets)
Link to comment
Share on other sites

Once upon a time, MM created a cache of it's patch configuration and only re-solved if the patches were altered. Is this still the case? Mine is doing a fresh solve at every load even if I haven't changed anything. 

Link to comment
Share on other sites

24 minutes ago, peteletroll said:

@Omnipius, check the Logs/ModuleManager/ModuleManager.log file, it says what changed.

[WRN 00:04:28.827] Errors in patch prevents the creation of the cache
[LOG 00:04:28.940] ModuleManager: 204742 patches applied, found <color=orange>2 errors</color>
2 errors related to GameData/KerbalismConfig/Support/SXT.cfg

Is there a way to override that warning and force cache creation?

I'm also trying to sort out what's wrong with SXT's Kerbalism config:

[LOG 00:01:27.289] Applying update KerbalismConfig/Support/SXT/@PART[SXTDepolyRTGI,SXTDepolyRTGII]:NEEDS[ProfileRealismOverhaul,SXT]:FOR[RP-0-Kerbalism] to SXT/Parts/StationsBases/Electrical/RTG/part.cfg/PART[SXTDepolyRTGII]
[ERR 00:01:27.290] Error - Cannot parse variable search when inserting new key capacity = #$../MODULE[ModuleGenerator]/OUTPUT_RESOURCE[ElectricCharge]/rate$
[LOG 00:01:27.290] Applying update KerbalismConfig/Support/SXT/@PART[SXTDepolyRTGI,SXTDepolyRTGII]:NEEDS[ProfileRealismOverhaul,SXT]:FOR[RP-0-Kerbalism] to SXT/Parts/StationsBases/Electrical/RTG/partBasic.cfg/PART[SXTDepolyRTGI]
[ERR 00:01:27.290] Error - Cannot parse variable search when inserting new key capacity = #$../MODULE[ModuleGenerator]/OUTPUT_RESOURCE[ElectricCharge]/rate$

 

Link to comment
Share on other sites

On 1/11/2021 at 5:57 AM, Omnipius said:

Is there a way to override that warning and force cache creation?

Yes. By fixing the patches with errors. I don't know of any other way.

 

On 1/11/2021 at 5:57 AM, Omnipius said:

I'm also trying to sort out what's wrong with SXT's Kerbalism config:

This is something you will need help from the SXT's maintainer - but asking help from the Kerbalism guys should help too, as something on Kerbalism could had changed and nobody remembered to update the SXT's support for it.

Link to comment
Share on other sites

I'm trying to write a patch to create 0.625m versions of the stock 1.258m fuel tanks.

I wrote this to make a 0.625m version of the FL-T100 Fuel Tank, and it worked perfectly:

Spoiler

+PART[fuelTankSmallFlat]
{
    @name = probeTank_Tiny
    @rescaleFactor = 0.5
    @node_stack_top[6] = 0
    @node_stack_bottom[6] = 0
    @entryCost = 600
    @cost = 75
    @title = 0 FS-T040
    @description = A small 40 liter LFO tank for probe size rockets.
    @mass = 0.0312
    @bulkheadProfiles = size0, srf
    @RESOURCE,0
    {
        @name = LiquidFuel
        @amount = 18
        @maxAmount = 18
    }
    @RESOURCE,1
    {
        @name = Oxidizer
        @amount = 22
        @maxAmount = 22
    }
}

So I copy-pasted it 3 times and changed the entries to make copies of the FT-200, FT-400 and FT-800.

Spoiler

+PART[fuelTankSmall]
{
    @name = probeTank_Small
    @rescaleFactor = 0.5
    @node_stack_top[6] = 0
    @node_stack_bottom[6] = 0
    @entryCost = 800
    @cost = 140
    @title = 0 FS-T080
    @description = A small 80 liter LFO tank for probe size rockets.
    @mass = 0.0625
    @bulkheadProfiles = size0, srf
    @RESOURCE,0
    {
        @name = LiquidFuel
        @amount = 36
        @maxAmount = 36
    }
    @RESOURCE,1
    {
        @name = Oxidizer
        @amount = 44
        @maxAmount = 44
    }
}

+PART[fuelTank]
{
    @name = probeTank
    @rescaleFactor = 0.5
    @node_stack_top[6] = 0
    @node_stack_bottom[6] = 0
    @entryCost = 1250
    @cost = 250
    @title = 0 FS-T125
    @description = A 125 liter LFO tank for probe size rockets.
    @mass = 0.125
    @bulkheadProfiles = size0, srf
    @RESOURCE,0
    {
        @name = LiquidFuel
        @amount = 56
        @maxAmount = 56
    }
    @RESOURCE,1
    {
        @name = Oxidizer
        @amount = 69
        @maxAmount = 69
    }
}

+PART[fuelTank_long]
{
    @name = probeTank_long
    @rescaleFactor = 0.5
    @node_stack_top[6] = 0
    @node_stack_bottom[6] = 0
    @entryCost = 2400
    @cost = 400
    @title = 0 FS-T250
    @description = A 250 liter LFO tank for probe size rockets.
    @mass = 0.25
    @bulkheadProfiles = size0, srf
    @RESOURCE,0
    {
        @name = LiquidFuel
        @amount = 112
        @maxAmount = 112
    }
    @RESOURCE,1
    {
        @name = Oxidizer
        @amount = 138
        @maxAmount = 138
    }
}

When I run this however, I get 4 errors.

Spoiler

[LOG 03:31:00.743] Log started at 2021-01-19 03:31:00.743
[LOG 03:31:01.644] Checking Cache
[LOG 03:31:01.806] SHA generated in 0.157s
[LOG 03:31:01.806]       SHA = 4D-76-74-E8-58-5C-63-03-F5-21-BE-B6-A6-EF-35-DF-16-CC-76-AE-69-C2-13-02-99-D9-86-DD-DF-5B-2C-49
[LOG 03:31:01.827] Changes :
Added   : zMyPatches/MM-ProbeTanks.cfg

[LOG 03:31:01.827] Cache SHA = F8-48-AA-8B-6F-46-B2-3C-E2-4F-BA-4D-1D-AB-DF-8F-6A-35-3E-6E-11-49-C2-FC-E7-27-3B-5A-4E-CB-8D-F3
[LOG 03:31:01.827] useCache = False
[LOG 03:31:01.828] Pre patch init
[LOG 03:31:01.986] compiling list of loaded mods...
Mod DLLs found:
  Name                                    Assembly Version         Assembly File Version    KSPAssembly Version      SHA256

  Assembly-CSharp                         0.0.0.0                  0.0.0.0                  1.10                     535f53fe218e045b57a9d56b78878c944261cf2a4a20b975b19ea8f58c423ec6
  ModuleManager                           4.1.4.0                  4.1.4.0                  2.5                      c3a771f61e578ac9e9d69ac642ddd98dde19de8e26635266876748c86b829d81
Non-DLL mods added (:FOR[xxx]):
Mods by directory (sub directories of GameData):
  Squad
  zMyPatches
Mods added by assemblies:

[LOG 03:31:01.988] Loading Physics.cfg
[LOG 03:31:01.993] Extracting patches
[LOG 03:31:02.062] Applying patches
[LOG 03:31:02.064] :INSERT (initial) pass
[LOG 03:31:02.184] :FIRST pass
[LOG 03:31:02.184] :LEGACY (default) pass
[LOG 03:31:02.208] Applying copy zMyPatches/MM-ProbeTanks/+PART[fuelTankSmallFlat] to Squad/Parts/FuelTank/Size1_Tanks/fuelTankT100.cfg/PART[fuelTankSmallFlat]
[ERR 03:31:02.210] Invalid Vector Index!
[ERR 03:31:02.210] Invalid Vector Index!
[LOG 03:31:02.211] Applying copy zMyPatches/MM-ProbeTanks/+PART[fuelTankSmall] to Squad/Parts/FuelTank/Size1_Tanks/fuelTankT200.cfg/PART[fuelTankSmall]
[ERR 03:31:02.213] Invalid Vector Index!
[ERR 03:31:02.213] Invalid Vector Index!
[LOG 03:31:02.213] Applying copy zMyPatches/MM-ProbeTanks/+PART[fuelTank] to Squad/Parts/FuelTank/Size1_Tanks/fuelTankT400.cfg/PART[fuelTank]
[LOG 03:31:02.215] Applying copy zMyPatches/MM-ProbeTanks/+PART[fuelTank_long] to Squad/Parts/FuelTank/Size1_Tanks/fuelTankT800.cfg/PART[fuelTank_long]
[LOG 03:31:02.223] :BEFORE[ASSEMBLY-CSHARP] pass
[LOG 03:31:02.223] :FOR[ASSEMBLY-CSHARP] pass
[LOG 03:31:02.223] :AFTER[ASSEMBLY-CSHARP] pass
[LOG 03:31:02.223] :BEFORE[MODULEMANAGER] pass
[LOG 03:31:02.223] :FOR[MODULEMANAGER] pass
[LOG 03:31:02.223] :AFTER[MODULEMANAGER] pass
[LOG 03:31:02.223] :BEFORE[SQUAD] pass
[LOG 03:31:02.223] :FOR[SQUAD] pass
[LOG 03:31:02.223] :AFTER[SQUAD] pass
[LOG 03:31:02.223] :BEFORE[ZMYPATCHES] pass
[LOG 03:31:02.223] :FOR[ZMYPATCHES] pass
[LOG 03:31:02.223] :AFTER[ZMYPATCHES] pass
[LOG 03:31:02.226] :FINAL pass
[LOG 03:31:02.226] Done patching
[WRN 03:31:02.227] Errors in patch prevents the creation of the cache
[LOG 03:31:02.364] ModuleManager: 4 patches applied, found <color=orange>4 errors</color>
4 errors related to GameData/zMyPatches/MM-ProbeTanks.cfg

[LOG 03:31:02.365] Ran in 0.720s
[LOG 03:31:02.369] Done!

 

I can't for the life of me see why these patches differ from the first. Can someone tell me what I am doing wrong?

I am using a clean install of KSP 1.10.1 with no mods (other than Module Manager) on Windows 10.

Edited by DialoMalison
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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