Jump to content

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


sarbian

Recommended Posts

10 minutes ago, ns88ns said:

Hi, community.

A quick question: is there a way/method to check whether an other node is defined from root path? E.g.: I would like to apply patch to a part only in case if a resource is already defined:


@PART[MyCoolPart]:AFTER[OtherCoolMod]
{
	(all the stuff)
}

but only if root node RESOURCE_DEFINITION[ResName] exists already?

Thank you in advance.

Typically you would use :NEEDS[CommunityResourcePack] or whatever mod defines the resource in question. I'm not aware of any way to test for a condition outside the PART other than NEEDS.

Link to comment
Share on other sites

Hi,

Having a problem with a mod, I suspect this is the problem:
 

@PART[~kerbalEVA*]:HAS[@MODULE[ModuleScienceExperiment],!MODULE[WBI*]]

This is supposed to apply to any part which doesn't contain "kerbalEVA*", but I don't think it's working

I actually need to exclude all of the following:

Quote

maleEVA
femaleEVA
kerbalEVA_RD_Exp
kerbalEVA_female_Exp
kerbalEVA_RD_Future
kerbalEVA_female_Future
kerbalEVA
kerbalEVAfemale
kerbalEVAVintage
kerbalEVAfemaleVintage.
kerbalEVAFuture
kerbalEVAfemaleFuture

Suggestions?

Link to comment
Share on other sites

30 minutes ago, linuxgurugamer said:

 


@PART[~kerbalEVA*]:HAS[@MODULE[ModuleScienceExperiment],!MODULE[WBI*]]

This is supposed to apply to any part which doesn't contain "kerbalEVA*", but I don't think it's working

This would be my guess:

@PART:HAS[~name[kerbalEVA*],@MODULE[ModuleScienceExperiment],!MODULE[WBI*]]

Link to comment
Share on other sites

1 hour ago, Jso said:

This would be my guess:

@PART:HAS[~name[kerbalEVA*],@MODULE[ModuleScienceExperiment],!MODULE[WBI*]]

Ok. What about this:

@PART:HAS[~name[kerbalEVA*],~name[*maleEVA],@MODULE[ModuleScienceExperiment],!MODULE[WBI*]]

That will cover all the EVA kerbals I listed earlier, just not sure about the leading asterick

 

Edit:  This is now working, thanks @Jso

Edited by linuxgurugamer
Link to comment
Share on other sites

Is there a way to only apply a patch if a variable is set to a value? Like if #$@MY_MODS_SETTINGS/USE_SETTING$ was set to true than certain patches should be applied, otherwise they're ignored? Like NEEDS but for variables?

Link to comment
Share on other sites

33 minutes ago, Citizen247 said:

Is there a way to only apply a patch if a variable is set to a value? Like if #$@MY_MODS_SETTINGS/USE_SETTING$ was set to true than certain patches should be applied, otherwise they're ignored? Like NEEDS but for variables?

As far as I know, you cannot check for variables in other nodes to apply a patch to something different. I tried it and failed miserably but I did something like that for my own config for simple fuel switch by adding the value from the settings to the parts I wanted to modify and then checking for the value in the actual patch.
For example:

Config file:

My_Mod_Settings
{
	change_this = true
}

1. Patch:

//This must adress everything which may or may not be patched depending on the settings
//Use multiple patches like this if you cannot adress everything in a single patch
@PART[*]:HAS[whatever_it_is_you_want_to_adress]
{
	//Dummy Module
	MODULE
    {
    	name = my_dummy
    	change_this = #$My_Mod_Settings/change_this$
    }
	
}

2. Patch:

//Actual patch to apply your changes
@PART[*]:HAS[@MODULE[my_dummy]:HAS[#change_this[true]]]
{
	//do whatevery you want to do
}

3. Patch:

//Cean up
@PART[*]:HAS[@MODULE[my_dummy]]
{
	!MODULE[my_dummy] {}
}

 

Link to comment
Share on other sites

2 hours ago, Citizen247 said:

Thanks.

I wonder if that approach would work by adding a dummy property rather than a module?

Should work as well, it's just important that you add the value you want to check for to the config node you want to modify. I've used a module because I had quite a few values to add and thought it would be more elegant to put all of them into a single module ;)

Link to comment
Share on other sites

I am trying to add ablator to some of the parts since x6.4 scale reentries get pretty hot for unshielded parts. 
I wrote the code, but it doesn't work and to be honest I have no idea where I made a mistake.

 

Spoiler

 


@PART[*]:HAS[#category[Ground]], HAS[#category[Structural], HAS[#category[FuelTank], HAS[#category[Aero], HAS[!MODULE[ModuleAblator]]]
{
	@MODULE
	{
		name = ModuleAblator
		ablativeResource = Ablator
		lossExp = -7500
		lossConst = 0.1
		pyrolysisLossFactor = 6000
		reentryConductivity = 0.01
		ablationTempThresh = 500
		
		useChar = True
		charModuleName = shieldChar
	}
	
	@RESOURCE
	{
		name = Ablator
		amount = 0
		maxAmount = 50
	}
}
@PART[*gear*]
{
	@MODULE
		{
			name = ModuleAblator
			ablativeResource = Ablator
			lossExp = -7500
			lossConst = 0.1
			pyrolysisLossFactor = 6000
			reentryConductivity = 0.01
			ablationTempThresh = 500
			
			useChar = True
			charModuleName = shieldChar
		}
		
		@RESOURCE
		{
			name = Ablator
			amount = 0
			maxAmount = 50
		}
}

 

 

 

ModuleAblator used is stock Squad module pulled from one of the heatshields. 
If I understand the syntax correctly, I want to:
1. Find all parts that belong to ground,structural, fuelTank and aero category...
1a. That do not already have a ModuleAblator.
2. Add ModuleAblator to those parts.
3. Add ablator resource set to start at 0 and max out at 50 units.
4. Do the same for all parts that have "gear" in name.

But I seem to be missing something, and I am all out of ideas.

Edited by Ja222
Link to comment
Share on other sites

14 hours ago, Ja222 said:

I am trying to add ablator to some of the parts since x6.4 scale reentries get pretty hot for unshielded parts. 
I wrote the code, but it doesn't work and to be honest I have no idea where I made a mistake.

 

  Hide contents

 



@PART[*]:HAS[#category[Ground]], HAS[#category[Structural], HAS[#category[FuelTank], HAS[#category[Aero], HAS[!MODULE[ModuleAblator]]]
{
	@MODULE
	{
		name = ModuleAblator
		ablativeResource = Ablator
		lossExp = -7500
		lossConst = 0.1
		pyrolysisLossFactor = 6000
		reentryConductivity = 0.01
		ablationTempThresh = 500
		
		useChar = True
		charModuleName = shieldChar
	}
	
	@RESOURCE
	{
		name = Ablator
		amount = 0
		maxAmount = 50
	}
}
@PART[*gear*]
{
	@MODULE
		{
			name = ModuleAblator
			ablativeResource = Ablator
			lossExp = -7500
			lossConst = 0.1
			pyrolysisLossFactor = 6000
			reentryConductivity = 0.01
			ablationTempThresh = 500
			
			useChar = True
			charModuleName = shieldChar
		}
		
		@RESOURCE
		{
			name = Ablator
			amount = 0
			maxAmount = 50
		}
}

 

 

 

ModuleAblator used is stock Squad module pulled from one of the heatshields. 
If I understand the syntax correctly, I want to:
1. Find all parts that belong to ground,structural, fuelTank and aero category...
1a. That do not already have a ModuleAblator.
2. Add ModuleAblator to those parts.
3. Add ablator resource set to start at 0 and max out at 50 units.
4. Do the same for all parts that have "gear" in name.

But I seem to be missing something, and I am all out of ideas.

It doesn’t work because of step 1:

It’s trying to find all parts that match ALL of the criteria. Which are 0 parts. 

Your next thought would be to replace the comma with a pipe, but you cannot filter with pipes in a HAS block. 

You’ll need to chop it up into 1 patch per category, or find a different property to filter by.

Also, @ is used to target an existing key/node. Since no specifier is given your @MODULE would modify the first module in the part. Since you want to add a new module, ditch the @. ;) 

Link to comment
Share on other sites

Thank you for answers :wink:

Unfortunately, I still seem to fail at implementing my code.

 

Spoiler

@PART[*]:HAS[category[Aero]]
{

	RESOURCE
	{
		name = Ablator
		amount = 0
		maxAmount = 50
	}
	
	MODULE
	{
		name = ModuleAblator
		ablativeResource = Ablator
		lossExp = -7500
		lossConst = 0.1
		pyrolysisLossFactor = 6000
		reentryConductivity = 0.01
		ablationTempThresh = 500
		
		useChar = false
	}
	
	
}

 

Code in the spoiler above goes without an error on load, and still does not add ablator resource to the parts in hangar.
I modified the stock ModuleAblator with simple "false" flag to useChar - it is pretty self explanatory. 

I dropped @'s as mentioned. Maybe I need to mark the patch as FINAL to make it work? I don't think I have any mod that would mess with it but I'll try.

Edited by Ja222
Link to comment
Share on other sites

On 5/12/2020 at 2:02 PM, Ja222 said:

I am trying to add ablator to some of the parts since x6.4 scale reentries get pretty hot for unshielded parts. 
I wrote the code, but it doesn't work and to be honest I have no idea where I made a mistake.

 

  Hide contents

 



@PART[*]:HAS[#category[Ground]], HAS[#category[Structural], HAS[#category[FuelTank], HAS[#category[Aero], HAS[!MODULE[ModuleAblator]]]
{
	@MODULE
	{
		name = ModuleAblator
		ablativeResource = Ablator
		lossExp = -7500
		lossConst = 0.1
		pyrolysisLossFactor = 6000
		reentryConductivity = 0.01
		ablationTempThresh = 500
		
		useChar = True
		charModuleName = shieldChar
	}
	
	@RESOURCE
	{
		name = Ablator
		amount = 0
		maxAmount = 50
	}
}
@PART[*gear*]
{
	@MODULE
		{
			name = ModuleAblator
			ablativeResource = Ablator
			lossExp = -7500
			lossConst = 0.1
			pyrolysisLossFactor = 6000
			reentryConductivity = 0.01
			ablationTempThresh = 500
			
			useChar = True
			charModuleName = shieldChar
		}
		
		@RESOURCE
		{
			name = Ablator
			amount = 0
			maxAmount = 50
		}
}

 

 

 

 

Okay so

  1. Don't put spaces in there.  KSP doesn't like them.  Nothing MM can do about this short of completely rewriting the parser.
  2. There's unfortunately no way to do multiple categories like that.  They have to be separate patches (or something like that)
  3. Only one top level HAS is allowed, any conditions have to be within that
  4. You seem to want to add the MODULE and RESOURCE, so get rid of the @ on each of them - @ is for editing an existing node, not adding a new one
Link to comment
Share on other sites

Greetings! I set up a MM patch to replace the title of two BDArmory parts, though my patch doesn't work for some reason, and I can't figure out why.

Nvm! My modules were correct but the mod includes :FINAL tags on its part names for some reason.

Edited by Avera9eJoe
Link to comment
Share on other sites

17 minutes ago, Avera9eJoe said:

Greetings! I set up a MM patch to replace the title of two BDArmory parts, though my patch doesn't work for some reason, and I can't figure out why.

Make sure the file is under GameData someplace.

Check the file extension and make sure it's actually .cfg and not .cfg.doc or whatever wordpad uses (folder options uncheck hide extentions for known file type or something along those lines).

Use Notepad or get NotePad++ for editing text files.

Link to comment
Share on other sites

5 hours ago, Jso said:

Make sure the file is under GameData someplace.

Check the file extension and make sure it's actually .cfg and not .cfg.doc or whatever wordpad uses (folder options uncheck hide extentions for known file type or something along those lines).

Use Notepad or get NotePad++ for editing text files.

It's already fixed, my patch was correct but BDA had strange custom patches that included :FINAL in the titles, so my patches weren't showing up :P

Edited by Avera9eJoe
Link to comment
Share on other sites

Instead of copying a part and deleting what I don't want, can I create a new part and add modules referenced in another part?

+MODULE[<what does a reference to a module in another part look like>] {}

Can I also encapsulate a NEEDS and HAS statement around several parts?

:NEEDS[<whatever mod>]
{
	PART {}
	PART {}
}

 

Link to comment
Share on other sites

2 hours ago, KrakenBeGone said:

Instead of copying a part and deleting what I don't want, can I create a new part and add modules referenced in another part?


+MODULE[<what does a reference to a module in another part look like>] {}

Yes, but you have to do it in a patch (MM doesn't look for anything but NEEDS in the orignal node

Spoiler

PART
{
    name = somePart
    
    MODULE
    {
        name = ModuleSomething
    }
}

PART
{
    name = someOtherPart
}

@PART[someOtherPart]
{
    #@PART[somePart]/MODULE[someModule] {}
}

 

 

2 hours ago, KrakenBeGone said:

Can I also encapsulate a NEEDS and HAS statement around several parts?

no

Edited by blowfish
Link to comment
Share on other sites

Hi all, 

Would like a little help here.

I need a patch to find all instances of one string and replace it with another.

This is to repoint some part textures to a new location for a texture.

Very specifically, I need this:

        texture = orange-jumbo-0, Squad/Parts/FuelTank/fuelTankJumbo-64/model000
        texture = orange-jumbo-1, Squad/Parts/FuelTank/fuelTankJumbo-64/model001

changed to this:

        texture = orange-jumbo-0, FuelTanksPlus/Squad/fuelTankJumbo-64/model000
        texture = orange-jumbo-1, FuelTanksPlus/Squad/fuelTankJumbo-65/model001

 

I'm a bit busy, and don't have time to puzzle this out, would appreciate any help

Thanks

 

LGG

Edit:  I have this working, but it's ugly:

@PART[*]:NEEDS[FuelTanksPlus]
{
	@MODEL
	{
		@texture,0 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64:
		@texture,1 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64:
		@texture,2 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64:
		@texture,3 ^= :Squad/Parts/FuelTank/fuelTankJumbo-64:FuelTanksPlus/Squad/fuelTankJumbo-64:
	}
}

 

When I didn't have the ,[0123], it only touched the first texture line, so I added the additional lines.  Is there a better way?

Edited by linuxgurugamer
Link to comment
Share on other sites

4 hours ago, linuxgurugamer said:

When I didn't have the ,[0123], it only touched the first texture line, so I added the additional lines.  Is there a better way?

should be as simple as @texture,*

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