Skip to content

Certain MM patch not applying #22

Closed

Description

@ProgrammerFailure

This mm patch does not seem to work:

Details

@part:HAS[@module[ModuleB9PartSwitch],#&/ModuleB9PartSwitch/baseVolume&>0]:FINAL
{

%MODULE

{

    name = WBIConvertibleStorage

    enableLogging = True

    showGUI = True

    confirmResourceSwitch = True

    defaultTemplate = LFO

    templateNodes = STORAGE_TEMPLATE

    templateTypes = Storage

    fieldReconfigurable = True

    resourcesToReplace = ALL

    capacityFactor = (#&/ModuleB9PartSwitch/baseVolume&)/1801

    logoPanelTransforms = decalPanel001, decalPanel002, decalPanel003, decalPanel004

    decalsVisible = false

    baseStorage = .001

    maxStorage = 9100

}

@MODULE[ModuleB9PartSwitch]
{
    %baseVolume = 0
}

}

All other MM patches seem to function
Here is the MM log:
MMPatch.log

Activity

  1. Lisias commented on Mar 8, 2024

    @Lisias

    [scratch that]

  2. self-assigned this
    on Mar 8, 2024
  3. Lisias commented on Mar 8, 2024

    @Lisias

    Ok. Let's try again.

    @part:HAS[@module[ModuleB9PartSwitch],#&/ModuleB9PartSwitch/baseVolume&>0]:FINAL
    {
    	%MODULE
    	{
    		name = WBIConvertibleStorage
    		enableLogging = True
    		showGUI = True
    		confirmResourceSwitch = True
    		defaultTemplate = LFO
    		templateNodes = STORAGE_TEMPLATE
    		templateTypes = Storage
    		fieldReconfigurable = True
    		resourcesToReplace = ALL
    		capacityFactor = (#&/ModuleB9PartSwitch/baseVolume&)/1801
    		logoPanelTransforms = decalPanel001, decalPanel002, decalPanel003, decalPanel004
    		decalsVisible = false
    		baseStorage = .001
    		maxStorage = 9100
    	}
    	@MODULE[ModuleB9PartSwitch]
    	{
    		%baseVolume = 0
    	}
    }
    

    You want to add WBIConvertibleStorage to every PART that have B9PS and those baseVolume attribute is bigger than 0.

    Well, I can't tell if the thing is working as intended only with the MM log. I need the ConfigCache too, so I can inspect whatever is there to see why this patch didn't worked as intended.

    Obviously, this patch will not be applied on parts without the :HAS satisfied - are you absolutely sure the patch applying B9PS was applied first? You see, :FINAL loses it's meaning if everybody uses it: patches are applied in alfabetical order when having the same priority.

    For example, the following patches WILL NOT work are intended:

    <file:GameData/AnAddOnStartingWIthA>
    @PART[*]:HAS[@MODULE[ModuleB9PartSwitch]]:FINAL
    {
    	yada yada yada
    }
    
    <file:GameData/BAddonStartingWithB>
    @PART[*]:HAS[!@MODULE[ModuleB9PartSwitch]]:FINAL
    {
    	%MODULE[ModuleB9PartSwitch]
    	{
    		yada yada yada
    	}
    }
    

    Because the first patch will be ran first for sure, when the B9PS patch below wasn't executed yet.

  4. ProgrammerFailure commented on Mar 8, 2024

    @ProgrammerFailure
    Author

    Forgot to mention, the patch is in the My_Patches file, but I have also tried it in a separate file, and when I did that, the file did not show up in "MMPatch.log". When I checked the ConfigSHA file, it was recorded by MM.

    Here is ConfigCache and ConfigSHA
    ConfigCache.txt
    ConfigSHA.txt

  5. ProgrammerFailure commented on Mar 8, 2024

    @ProgrammerFailure
    Author

    Regarding order of patches, I have the near future mods which use B9PS. Those have part definitions, so it should apply before the :FINAL right? Those parts have functional B9PS switchers.

  6. Lisias commented on Mar 8, 2024

    @Lisias

    Forgot to mention, the patch is in the My_Patches file, but I have also tried it in a separate file, and when I did that, the file did not show up in "MMPatch.log". When I checked the ConfigSHA file, it was recorded by MM.

    Attach the whole patch file too. I think things are slightly simpler than it looks.

    If I would write that pach, I would write it as:

    @PART[*]:HAS[@MODULE[ModuleB9PartSwitch],#&/ModuleB9PartSwitch/baseVolume&>0]:FINAL
    {
    	%MODULE
    	{
    		name = WBIConvertibleStorage
    		enableLogging = True
    		showGUI = True
    		confirmResourceSwitch = True
    		defaultTemplate = LFO
    		templateNodes = STORAGE_TEMPLATE
    		templateTypes = Storage
    		fieldReconfigurable = True
    		resourcesToReplace = ALL
    		capacityFactor = (#&/ModuleB9PartSwitch/baseVolume&)/1801
    		logoPanelTransforms = decalPanel001, decalPanel002, decalPanel003, decalPanel004
    		decalsVisible = false
    		baseStorage = .001
    		maxStorage = 9100
    	}
    	@MODULE[ModuleB9PartSwitch]
    	{
    		%baseVolume = 0
    	}
    }
    

    Case matters.

  7. Lisias commented on Mar 8, 2024

    @Lisias

    As well the location of the file. Tell me the full patchname of the patchfile too.

  8. ProgrammerFailure commented on Mar 8, 2024

    @ProgrammerFailure
    Author

    Full patch:
    My_Patches.txt
    The location of the file is "D:\Games\KSP instances\Kerbal Space Program\GameData\My patches\My_Patches.cfg"

  9. Lisias commented on Mar 8, 2024

    @Lisias

    Well, the best way to see what happens is running it on my rig. If course no patches will be applied, as I don't have anything installed on it, but I will be able to at least see them being deleted, what I didn't found on your log.

    I will be back to you in half an hour give or take.

  10. ProgrammerFailure commented on Mar 8, 2024

    @ProgrammerFailure
    Author

    I will try your updated patch soon

  11. Lisias commented on Mar 8, 2024

    @Lisias

    Weird... I installed B9PS on my rig just to see the patching happening and... you appears to be right. MM is silently ignoring the patches mentioning baseVolume, but it's applying the others.

    I think there's a small syntax error somewhere on this file. MM is absolutely tragic on handling errors. It's really shameful.

  12. Lisias commented on Mar 8, 2024

    @Lisias

    Uhh... WAIT... Why are you using &? If you want the value of something you use #$....$ (dollar sign)!

    & is used for boolean operations on conditional clausues (:HAS, etc) and for creating nodes...

  13. Lisias commented on Mar 8, 2024

    @Lisias

    The patch looks right (once you use $ instead of &). I had toyed a bit with this on Forum once.

    However, it is being ignored on my rig too.

  14. ProgrammerFailure commented on Mar 8, 2024

    @ProgrammerFailure
    Author

    I wrote the patch after checking the Sarbian MM wiki, where it said to use &. Must have misinterpreted something. So I should replace & with $? I'll test that when I get home.

  15. 8 remaining items

  16. Lisias commented on Mar 8, 2024

    @Lisias

    Edit: I have checked some part configs, and it seems like the problematic parts have no baseVolume; they just have resource values and a B9PartSwitch module. I probably just need to change the :HAS condition.

    Completely overlook it. Change to:

    		capacityFactor = #$/ModuleB9PartSwitch/baseVolume$
    		capacityFactor /= 1801
    

    MM doesn't do math without some effort.

  17. ProgrammerFailure commented on Mar 9, 2024

    @ProgrammerFailure
    Author

    This throws the following error:

    Details

    [ModuleManager] INFO: Applying update My patches/Edited_WBI_Convertible_Storage/@part:HAS[@module[ModuleB9PartSwitch]:HAS[#baseVolume[>0]]]:FINAL to CryoTanks/Parts/HydrogenTanks/hydrogen-inline/hydrogen-10-1.cfg/PART[hydrogen-10-1]
    [ModuleManager] ERROR: Error - Cannot parse variable search when inserting new key capacityFactor = #$/ModuleB9PartSwitch/baseVolume$ at Log:0

    full MMPatch.log:
    MMPatch.log

    The patch in question:

    Edited_WBI_Convertible_Storage.cfg.txt

  18. Lisias commented on Mar 9, 2024

    @Lisias

    My bad. The code I wrote was trying to fetch the baseVolume from a node labeled ModuleB9PartSwitch inside the current section (a "son"), not outside it (a "brother"). I also failed on specifying the node's label (MODULE).

    Additionally, I forgot the @ on the division statement. You can't apply math statements on values that doesn't previously exists, so the need for @.

                    capacityFactor = #$../MODULE[ModuleB9PartSwitch]/baseVolume$
                    @capacityFactor /= 1801
    

    I tried this changes before publishing it to you, it worked as intended here.

    And yeah, I find all these little deviations from the common sense absolutely annoying. Doing it when sleepy is, additionally, not exactly the best of ideas.

  19. ProgrammerFailure commented on Mar 9, 2024

    @ProgrammerFailure
    Author

    This patch has a weird effect; previously it was throwing ~100 something errors, now it throws just 38. Still seems like capacityFactor defaulting to 1, because all parts had the same capacity in-game.

    This is the error it throws now:

    Details

    [ModuleManager] INFO: Applying update My patches/Edited_WBI_Convertible_Storage/@part:HAS[@module[ModuleB9PartSwitch]:HAS[#baseVolume[>0]]]:FINAL to CryoTanks/Parts/HydrogenTanks/hydrogen-inline/hydrogen-10-1.cfg/PART[hydrogen-10-1]
    [ModuleManager] WARNING: Cannot find key baseVolume in MODULE
    [ModuleManager] ERROR: Error - Cannot parse variable search when inserting new key capacityFactor = #$../MODULE[ModuleB9PartSwitch]/baseVolume$ at Log:0

    MMPatch.log
    Edited_WBI_Convertible_Storage.cfg.txt

    The patch looks correct to me, so I don't understand the problem.

    Edit: Found the error; the patch applies to parts without a baseVolume as well as parts with baseVolume > 0. The :HAS condition is definitely broken.

  20. Lisias commented on Mar 9, 2024

    @Lisias

    On a side note, you will find some nice patches here:

    https://forum.kerbalspaceprogram.com/topic/139980-130-community-database-of-module-manager-patches-for-stock-ksp/

    I'm investigating this new issue now - I didn't saw this one coming, I don't know B9PS and I had assumed that every part had a baseVolume.

  21. Lisias commented on Mar 9, 2024

    @Lisias

    On a personal note, this is yet another MM idiosyncrasy that I don't understand why wasn't fixed by the mainstream. If the value doesn't exists, it should return false, damnit!!. This is a :HAS clause after all, the absense of the value means the :HAS should return false and life goes on!

    Note to my future self

    I'm using Forum MM for these testings to rule out any hypothetical side effect induced by my fork.

  22. Lisias commented on Mar 9, 2024

    @Lisias

    Edit: Found the error; the patch applies to parts without a baseVolume as well as parts with baseVolume > 0. The :HAS condition is definitely broken.

    Yep. Try this:

    @PART:HAS[@MODULE[ModuleB9PartSwitch]:HAS[baseVolume,#baseVolume[>0]]]:FINAL
    { yada yada yada }
    

    It appears to work on my synthetic test bed.

    Note to my future self

    Synthetic test bed follows (not to be used by the user!!):

    @PART
    {
    	&MODULE[ModuleB9PartSwitch]
    	{
    		thisIsNotBaseVolume = 0
    	}
    }
    
    @PART:HAS[@MODULE[ModuleB9PartSwitch]:HAS[baseVolume,#baseVolume[>0]]]:FINAL
    {
    	%MODULE[WBIConvertibleStorage]
    	{
    		enableLogging = True
    		showGUI = True
    		confirmResourceSwitch = True
    		defaultTemplate = LFO
    		templateNodes = STORAGE_TEMPLATE
    		templateTypes = Storage
    		fieldReconfigurable = True
    		resourcesToReplace = ALL
    		capacityFactor = #$../MODULE[ModuleB9PartSwitch]/baseVolume$
    		@capacityFactor /= 1801
    		logoPanelTransforms = decalPanel001, decalPanel002, decalPanel003, decalPanel004
    		decalsVisible = false
    		baseStorage = .001
    		maxStorage = 9100
    	}
    }
    
  23. Lisias commented on Mar 9, 2024

    @Lisias

    @ProgrammerFailure can I close this "ticket" as concluded?

  24. ProgrammerFailure commented on Mar 10, 2024

    @ProgrammerFailure
    Author

    This change seems to have made MM ignore the patch again. At this point, I am just closing the ticket and giving up on converting the tanks.

  25. Lisias commented on Mar 10, 2024

    @Lisias

    This change seems to have made MM ignore the patch again. At this point, I am just closing the ticket and giving up on converting the tanks.

    @ProgrammerFailure , my bad (again). Typo.

    The correct patch would be:

    @PART:HAS[@MODULE[ModuleB9PartSwitch]:HAS[#baseVolume,#baseVolume[>0]]]:FINAL
    {
    	%MODULE[WBIConvertibleStorage]
    	{
    		enableLogging = True
    		showGUI = True
    		confirmResourceSwitch = True
    		defaultTemplate = LFO
    		templateNodes = STORAGE_TEMPLATE
    		templateTypes = Storage
    		fieldReconfigurable = True
    		resourcesToReplace = ALL
    		capacityFactor = #$../MODULE[ModuleB9PartSwitch]/baseVolume$
    		@capacityFactor /= 1801
    		logoPanelTransforms = decalPanel001, decalPanel002, decalPanel003, decalPanel004
    		decalsVisible = false
    		baseStorage = .001
    		maxStorage = 9100
    	}
    }
    

    (note the extra # on the :HAS before the first baseVolume).

    Note to my future self:

    Synthetic test (not to be used by the user):

    @PART[trussAdapter]
    {
    	&MODULE[ModuleB9PartSwitch]
    	{
    		baseVolume = 2000
    	}
    }
    @PART
    {
    	&MODULE[ModuleB9PartSwitch]
    	{
    		thisIsNotBaseVolume = 0
    	}
    }
    @PART:HAS[@MODULE[ModuleB9PartSwitch]:HAS[#baseVolume,#baseVolume[>0]]]:FINAL
    {
    	%MODULE[WBIConvertibleStorage]
    	{
    		enableLogging = True
    		showGUI = True
    		confirmResourceSwitch = True
    		defaultTemplate = LFO
    		templateNodes = STORAGE_TEMPLATE
    		templateTypes = Storage
    		fieldReconfigurable = True
    		resourcesToReplace = ALL
    		capacityFactor = #$../MODULE[ModuleB9PartSwitch]/baseVolume$
    		@capacityFactor /= 1801
    		logoPanelTransforms = decalPanel001, decalPanel002, decalPanel003, decalPanel004
    		decalsVisible = false
    		baseStorage = .001
    		maxStorage = 9100
    	}
    }
    

    MM Config Cache: ConfigCache.cfg.zip

    Evidence:

    Only trussAdapter have the WBIConvertibleStorage now, and with the correct capacityFactor:

    UrlConfig
    {
    	parentUrl = Squad/Parts/Structural/trussGirderAdapter/trussGirderAdapter.cfg
    	PART
    	{
    		name = trussAdapter
    		module = Part
    		author = NovaSilisko
    		mesh = model.mu
    		rescaleFactor = 1
    		node_stack_bottom = 0.0, -0.4108305, 0.0, 0.0, -1.0, 0.0, 1
    		node_stack_top = 0.0, 0.6493708, 0.0, 0.0, 1.0, 0.0, 1
    		TechRequired = specializedConstruction
    		entryCost = 4800
    		cost = 50
    		category = Structural
    		subcategory = 0
    		title = Modular Girder Adapter
    		manufacturer = Maxo Construction Toys
    		description = This piece allows you to attach Modular Girder parts to standard 1.25m attachment points.
    		attachRules = 1,0,1,1,0
    		mass = 0.25
    		dragModelType = default
    		maximum_drag = 0.2
    		minimum_drag = 0.2
    		angularDrag = 1
    		crashTolerance = 80
    		breakingForce = 200
    		breakingTorque = 200
    		maxTemp = 2000
    		bulkheadProfiles = size1
    		tags = connect frame scaffold structur strut truss
    		MODULE
    		{
    			name = ModuleCargoPart
    			packedVolume = 1700
    		}
    		MODULE
    		{
    			name = FundsKeeper
    		}
    		MODULE
    		{
    			name = Refunding
    			active = True
    		}
    		MODULE
    		{
    			name = StealBackMyFunds
    			active = True
    		}
    		MODULE
    		{
    			name = TweakScale
    			type = stack
    			defaultScale = 1.25
    		}
    		MODULE
    		{
    			name = ModuleB9PartSwitch
    			baseVolume = 2000
    		}
    		MODULE
    		{
    			name = AttachedOnEditor
    			active = True
    		}
    		MODULE
    		{
    			name = WBIConvertibleStorage
    			enableLogging = True
    			showGUI = True
    			confirmResourceSwitch = True
    			defaultTemplate = LFO
    			templateNodes = STORAGE_TEMPLATE
    			templateTypes = Storage
    			fieldReconfigurable = True
    			resourcesToReplace = ALL
    			capacityFactor = 1.11049416990561           <----- **HERE!!!**
    			logoPanelTransforms = decalPanel001, decalPanel002, decalPanel003, decalPanel004
    			decalsVisible = false
    			baseStorage = .001
    			maxStorage = 9100
    		}
    	}
    }
    
    
  26. reopened this on Mar 10, 2024
  27. Lisias commented on Mar 10, 2024

    @Lisias

    Reopening it to move it into a discussion.

  28. locked and limited conversation to collaborators on Mar 10, 2024
  29. converted this issue into a discussion #24 on Mar 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

supportsupport (no bug)

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions