Jump to content

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


sarbian

Recommended Posts

2 hours ago, Brucey said:

 

I'd call myself a novice.  I know enough to go find all the parts with a text editor and make changes manually.

I'm wondering if there's code that just says, "for all parts with reaction wheels, multiply torque values by x"

Okay, I'll walk you through it.  In spoiler tags for those who don't wish to see a long tutorial

Spoiler

General info on how MM works: all .cfg files in GameData (with a few exceptions) are loaded into something called the game database in KSP.  Before any parts (or other stuff) are loaded, ModuleManager goes through that database and identifies patches that need to be made.

MM uses the @ symbol to identify edits to existing nodes.  We want to edit all PART nodes


@PART[*] { }

All parts have a name = something field, which MM matches based on what's inside the square brackets [ ].  * means match anything.  If you only wanted to match parts starting with KW (for instance), it would be @PART[KW*].  If you only wanted to match a specific part, it would be @PART[MyPart]

This patch doesn't do anything yet, since there's nothing between the curly braces { }

Now, we really only want to match parts with ModuleReactionWheel:


@PART[*]:HAS[@MODULE[ModuleReactionWheel]] { }

The :HAS block tells MM to look for stuff in the node and only match if conditions are met.  @MODULE[ModuleReactionWheel] tells it to look for a MODULE node with name = ModuleReactionWheel (@ in this context means has this node, ! means does not have this node, # means has this value, ~ means does not have this value).

Now, to actually do something.  Once these nodes are matched, we want to actually edit the ModuleReactionWheel


@PART[*]:HAS[@MODULE[ModuleReactionWheel]]
{
    @MODULE[ModuleReactionWheel] { }
}

Where here again @ means modify this node or value.

Then we want to modify the pitchTorque, yawTorque, and rollTorque inside that.  Let's say you wanted to divide each by a factor of 5


@PART[*]:HAS[@MODULE[ModuleReactionWheel]]
{
    @MODULE[ModuleReactionWheel]
    {
    	@pitchTorque /= 5
        @yawTorque /= 5
        @rollTorque /= 5
    }
}

You can also use other mathematical operators, including *=, +=, and -=

Oh, and we should make sure it runs at the right time.


@PART[*]:HAS[@MODULE[ModuleReactionWheel]]:FINAL
{
    @MODULE[ModuleReactionWheel]
    {
    	@pitchTorque /= 5
        @yawTorque /= 5
        @rollTorque /= 5
    }
}

The :FINAL will tell MM to run this after all other patches (except those also marked :FINAL).  It's not recommended to use :FINAL in an actual mod that will be distributed (when to run should be specified explicitly in that case), but for personal patches it's fine.

Hope that helps.

 

Edited by blowfish
Link to comment
Share on other sites

24 minutes ago, blowfish said:

Okay, I'll walk you through it.  In spoiler tags for those who don't wish to see a long tutorial

  Reveal hidden contents

General info on how MM works: all .cfg files in GameData (with a few exceptions) are loaded into something called the game database in KSP.  Before any parts (or other stuff) are loaded, ModuleManager goes through that database and identifies patches that need to be made.

MM uses the @ symbol to identify edits to existing nodes.  We want to edit all PART nodes



@PART[*] { }

All parts have a name = something field, which MM matches based on what's inside the square brackets [ ].  * means match anything.  If you only wanted to match parts starting with KW (for instance), it would be @PART[KW*].  If you only wanted to match a specific part, it would be @PART[MyPart]

This patch doesn't do anything yet, since there's nothing between the curly braces { }

Now, we really only want to match parts with ModuleReactionWheel:



@PART[*]:HAS[@MODULE[ModuleReactionWheel]] { }

The :HAS block tells MM to look for stuff in the node and only match if conditions are met.  @MODULE[ModuleReactionWheel] tells it to look for a MODULE node with name = ModuleReactionWheel (@ in this context means has this node, ! means does not have this node, # means has this value, ~ means does not have this value).

Now, to actually do something.  Once these nodes are matched, we want to actually edit the ModuleReactionWheel



@PART[*]:HAS[@MODULE[ModuleReactionWheel]]
{
    @MODULE[ModuleReactionWheel] { }
}

Where here again @ means modify this node or value.

Then we want to modify the pitchTorque, yawTorque, and rollTorque inside that.  Let's say you wanted to divide each by a factor of 5



@PART[*]:HAS[@MODULE[ModuleReactionWheel]]
{
    @MODULE[ModuleReactionWheel]
    {
    	@pitchTorque /= 5
        @yawTorque /= 5
        @rollTorque /= 5
    }
}

You can also use other mathematical operators, including *=, +=, and -=

Oh, and we should make sure it runs at the right time.



@PART[*]:HAS[@MODULE[ModuleReactionWheel]]:FINAL
{
    @MODULE[ModuleReactionWheel]
    {
    	@pitchTorque /= 5
        @yawTorque /= 5
        @rollTorque /= 5
    }
}

The :FINAL will tell MM to run this after all other patches (except those also marked :FINAL).  It's not recommended to use :FINAL in an actual mod that will be distributed (when to run should be specified explicitly in that case), but for personal patches it's fine.

Hope that helps.

 

Super-duper helpful!  Thanks you so much.

Link to comment
Share on other sites

A super dumb question that I am very sorry if it's already been asked and answered.  If I am not making my own mods, do I need to add module manager to the list of mods CKAN downloads?  I am a little confused on if everyone includes this automatically with their mods, and if adding a specific mm download messes that up.

Link to comment
Share on other sites

1 minute ago, jpinard said:

A super dumb question that I am very sorry if it's already been asked and answered.  If I am not making my own mods, do I need to add module manager to the list of mods CKAN downloads?  I am a little confused on if everyone includes this automatically with their mods, and if adding a specific mm download messes that up.

If any of your mods depend on ModuleManager, then CKAN should install it automatically assuming their metadata is set up correctly.  CKAN usually doesn't install dependencies from specific mods' downloads, but rather downloads the dependencies separately and installs them.

Link to comment
Share on other sites

9 hours ago, blowfish said:

If any of your mods depend on ModuleManager, then CKAN should install it automatically assuming their metadata is set up correctly.  CKAN usually doesn't install dependencies from specific mods' downloads, but rather downloads the dependencies separately and installs them.

Great, thanks for explaining that blowfish!

Link to comment
Share on other sites

I'm trying to understand a thing, patch has this: 

@PART[S_HAHM_P]:NEEDS[RemoteTech] 
{
	!MODULE[ModuleDataTransmitter]{}
	@MODULE[ModuleAnimateGeneric]
	{
		%allowManualControl = true
	}
	%TechRequired = precisionEngineering
	%MODULE[ModuleRTAntenna] 
	{
		%Mode0DishRange = 0
		%Mode1DishRange = 60000000
		%EnergyCost = 0.1
		%MaxQ = 6000
		%DishAngle = 3
		%DeployFxModules = 0
		%TRANSMITTER
		{
			%PacketInterval = 0.3
			%PacketSize = 2
			%PacketResourceCost = 0.5
		}
	}	
	%MODULE[ModuleSPUPassive] {}
}

But RemoteTech isn't installed. Looking into alt-F12 menus, i see that the patch was applied even though the condition wasn't fulfilled, and yes i did reverify that RemoteTech wasn't there.

Edited by Mokmo
Missing words
Link to comment
Share on other sites

Hey guys, what am I doing wrong here.  I have this script that used to work in 1.0.5 but now it seems as though it does not on 1.1 with the latest module manager.  Any ideas?

@PHYSICSGLOBALS
{
    prelaunchDefaultThrottle = 0
}

The logs seems to indicate the patch is being loaded, but the throttle does not start at 0.

Edited by Alshain
Link to comment
Share on other sites

4 minutes ago, Alshain said:

Hey guys, what am I doing wrong here.  I have this script that used to work in 1.0.5 but now it seems as though it does not on 1.1 with the latest module manager.  Any ideas?

I do not grok the module manager syntax, but might it be because the prelaunchDefaultThrottle line now exists in 1.1 by default, and it didn't in 1.0.5?

Link to comment
Share on other sites

2 minutes ago, razark said:

I do not grok the module manager syntax, but might it be because the prelaunchDefaultThrottle line now exists in 1.1 by default, and it didn't in 1.0.5?

Hmm, could be.  Maybe I have to modify the value instead of adding it now.

 

EDIT: Yep, that was it.  New Script:

@PHYSICSGLOBALS
{
    @prelaunchDefaultThrottle = 0
}

 

Edited by Alshain
Link to comment
Share on other sites

42 minutes ago, Mokmo said:

I'm trying to understand a thing, patch has this: 

[...]

But RemoteTech isn't installed. Looking into alt-F12 menus, i see that the patch was applied even though the condition wasn't fulfilled, and yes i did reverify that RemoteTech wasn't there.

Hard to tell without a log. Are you sure you do not have a RemoteTech directory ?

Link to comment
Share on other sites

30 minutes ago, sarbian said:

Hard to tell without a log. Are you sure you do not have a RemoteTech directory ?

Question: After looking into my logs, another mod is using "FOR[RemoteTech]" and the "Non-DLL mods added (:FOR[xxx]):" has it listed. 
Does it mean the patcher now assumes RemoteTech is there ? 
I might have found my issue

 

Link to comment
Share on other sites

10 minutes ago, Mokmo said:

Question: After looking into my logs, another mod is using "FOR[RemoteTech]" and the "Non-DLL mods added (:FOR[xxx]):" has it listed. 
Does it mean the patcher now assumes RemoteTech is there ? 
I might have found my issue

 

Yes, it should do a NEED instead FOR.

Link to comment
Share on other sites

Could someone explain to me :FOR  ? Such as in planetary base systems, @PART[KKAOSS_LS_container_greenhouse]:FOR[PlanetarySurfaceStructures]:NEEDS[TacLifeSupport] , what exactly does the :FOR[PlanetarySurfaceStructures] do?

Edited by lagcity613
Link to comment
Share on other sites

5 minutes ago, sarbian said:

For tell MM that a mod called "PlanetarySurfaceStructures" is present. So other patch with :NEED[PlanetarySurfaceStructures] will be executed.

Thank you ^.^ I'd seen this in other mod's patches, but I could never find what it was meant to do.  Is it possible to edit something like "PART:NEEDS[TacLifeSupport|USILifeSupport|IFILifeSupport|Snacks]" With a patch, to add |Kerbalism ?

Edited by lagcity613
Link to comment
Share on other sites

@sarbian I just tried compiling MM from source and running the included test cases and I got a failure.  Is this something to be worried about, or just an issue with my setup?

Spoiler

[ModuleManager] Test NodeInsert[0] failed as expected output and actual output differ.
expected:
MMTEST
{
	name = nodeInsert
	MODULE
	{
		name = module0
	}
	MODULE
	{
		name = module1
	}
	MODULE
	{
		name = module2
	}
	MODULE
	{
		name = module999
	}
}

Actually got:
MMTEST
{
	name = nodeInsert
	MODULE
	{
		name = module1
	}
	MODULE
	{
		name = module2
	}
	MODULE,0
	{
		name = module0
	}
	MODULE,9999
	{
		name = module999
	}
}

 

 

Link to comment
Share on other sites

Tried searching but this IPS4 forum software is crap for fiddly details.

I think there's there a MM syntax qualifier similar to ":FINAL" but executes the changes first, before other changes without qualifiers.  Is it ":START" or ":FIRST" or something else?

Link to comment
Share on other sites

v2.6.23 is out

  • @blowfish patch to add & operator: insert only if it doesn't already exist
  • Fix for the insert NODE at position keeping the index in the node name that blowfish found
  • fix for nested constraint not looking past the first result

@Andem Changing a node is easy. I don't have the cfg for the part you talk about but it should look like :

@PART[megalador]
{
  @node_attach = the new values you want
}

It should work unless it uses more advanced config.

Edited by sarbian
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...