Atlas Gaming Posted December 19, 2020 Share Posted December 19, 2020 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$ } } Quote Link to comment Share on other sites More sharing options...
blowfish Posted December 22, 2020 Share Posted December 22, 2020 On 12/19/2020 at 11: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$ } } Expand 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 Quote Link to comment Share on other sites More sharing options...
Atlas Gaming Posted December 22, 2020 Share Posted December 22, 2020 (edited) Turns out everything works... ended up making a mod that adds stock inventory to all mod capsules as well as duplicated KIS inventory to be stock as well and published it the other day. Edited December 22, 2020 by Atlas Gaming Quote Link to comment Share on other sites More sharing options...
cyberKerb Posted December 23, 2020 Share Posted December 23, 2020 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] ] ] {} Quote Link to comment Share on other sites More sharing options...
Atlas Gaming Posted December 23, 2020 Share Posted December 23, 2020 (edited) 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 December 23, 2020 by Atlas Gaming Quote Link to comment Share on other sites More sharing options...
hemeac Posted December 23, 2020 Share Posted December 23, 2020 @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]] {} Quote Link to comment Share on other sites More sharing options...
cyberKerb Posted December 23, 2020 Share Posted December 23, 2020 On 12/23/2020 at 3:18 AM, 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]] {} Expand Oops - yep - you're right about that. Thanks for the catch! I'm guessing I got the brackets correct then cheers Quote Link to comment Share on other sites More sharing options...
Atlas Gaming Posted December 23, 2020 Share Posted December 23, 2020 (edited) 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 On 12/23/2020 at 3:18 AM, hemeac said: @rated_ignitions ^= :\.\d+:: // Floor value to get an integer Expand Edited December 23, 2020 by Atlas Gaming Quote Link to comment Share on other sites More sharing options...
hemeac Posted December 23, 2020 Share Posted December 23, 2020 On 12/23/2020 at 3:23 AM, 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 Expand @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 Quote Link to comment Share on other sites More sharing options...
Atlas Gaming Posted December 23, 2020 Share Posted December 23, 2020 Thank you thank you! Totally worked! And I even used it to simplify another mod KIFA as well! Cheers mate! Quote Link to comment Share on other sites More sharing options...
alartor Posted December 24, 2020 Share Posted December 24, 2020 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! Quote Link to comment Share on other sites More sharing options...
OHara Posted December 29, 2020 Share Posted December 29, 2020 (edited) 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 December 29, 2020 by OHara repair link Quote Link to comment Share on other sites More sharing options...
NyanTurian Posted December 30, 2020 Share Posted December 30, 2020 (edited) 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 January 1, 2021 by NyanTurian solution found Quote Link to comment Share on other sites More sharing options...
Heliocentric Posted December 30, 2020 Share Posted December 30, 2020 I cant reach the download site? Quote Link to comment Share on other sites More sharing options...
sarbian Posted December 30, 2020 Author Share Posted December 30, 2020 On 12/30/2020 at 9:10 PM, HelioCentric said: I cant reach the download site? Expand It works fine so it is on your end. Quote Link to comment Share on other sites More sharing options...
blowfish Posted January 2, 2021 Share Posted January 2, 2021 (edited) On 12/29/2020 at 6:29 PM, OHara said: Maybe the new parameter 'partRBMassMin' is read at a different time than the other variables are read from 'Physics.cfg' Expand 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 January 2, 2021 by blowfish Quote Link to comment Share on other sites More sharing options...
OHara Posted January 4, 2021 Share Posted January 4, 2021 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? Expand 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. Quote Link to comment Share on other sites More sharing options...
blowfish Posted January 9, 2021 Share Posted January 9, 2021 On 1/4/2021 at 12:58 AM, 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. Expand 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. Quote Link to comment Share on other sites More sharing options...
Lisias Posted January 10, 2021 Share Posted January 10, 2021 (edited) On 1/9/2021 at 8:09 PM, 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. Expand 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 January 10, 2021 by Lisias post edit (in brackets) Quote Link to comment Share on other sites More sharing options...
Omnipius Posted January 11, 2021 Share Posted January 11, 2021 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. Quote Link to comment Share on other sites More sharing options...
peteletroll Posted January 11, 2021 Share Posted January 11, 2021 @Omnipius, check the Logs/ModuleManager/ModuleManager.log file, it says what changed. Quote Link to comment Share on other sites More sharing options...
Omnipius Posted January 11, 2021 Share Posted January 11, 2021 On 1/11/2021 at 8:29 AM, peteletroll said: @Omnipius, check the Logs/ModuleManager/ModuleManager.log file, it says what changed. Expand [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$ Quote Link to comment Share on other sites More sharing options...
Lisias Posted January 12, 2021 Share Posted January 12, 2021 On 1/11/2021 at 8:57 AM, Omnipius said: Is there a way to override that warning and force cache creation? Expand Yes. By fixing the patches with errors. I don't know of any other way. On 1/11/2021 at 8:57 AM, Omnipius said: I'm also trying to sort out what's wrong with SXT's Kerbalism config: Expand 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. Quote Link to comment Share on other sites More sharing options...
DialoMalison Posted January 19, 2021 Share Posted January 19, 2021 (edited) 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: Reveal hidden contents +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. Reveal hidden contents +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. Reveal hidden contents [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 January 19, 2021 by DialoMalison Quote Link to comment Share on other sites More sharing options...
VoidSquid Posted January 19, 2021 Share Posted January 19, 2021 You could use this mod which is 0.625 m centric Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.