Jump to content

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


sarbian

Recommended Posts

Hello!

I'm trying to write a patch that modifies the energy usage on RemoteTech2 dishes.

@PART[*]:HAS[@MODULE[ModuleRTAntenna]]:FINAL
{
	@MODULE[ModuleRTAntenna]
	{
		@EnergyCost *= 0.50
	}
}

This is what I have. However, this also applies to the omnidirectional antennae from the same mod. How would I go about filtering for only the dishes?

Omni antennae look like this:

@PART[RTShortAntenna1]:FOR[RemoteTech]
{
	%TechRequired = start
	%MODULE[ModuleRTAntenna] {
		%IsRTActive = true
		%Mode0OmniRange = 0
		%Mode1OmniRange = 500000
		%EnergyCost = 0.01
		
		%TRANSMITTER {
			%PacketInterval = 0.3
			%PacketSize = 2
			%PacketResourceCost = 15.0
		}
	}
	
	%MODULE[ModuleSPUPassive] {}
}

Dishes look like this:

@PART[RTShortDish2]:FOR[RemoteTech]
{
	%TechRequired = electrics
	%MODULE[ModuleRTAntenna] {
		%Mode0DishRange = 0
		%Mode1DishRange = 90000000
		%EnergyCost = 0.82
		%DishAngle = 25.0
		
		%TRANSMITTER {
			%PacketInterval = 0.3
			%PacketSize = 2
			%PacketResourceCost = 15.0
		}
	}
	
	%MODULE[ModuleSPUPassive] {}
}

My first thought was to try to filter on DishAngle, but sadly that's where my skill with MM ends. Any help is appreciated.

EDIT:

OK, after some tinkering and help from the IRC chat, I got it working with this line:

@PART[*]:HAS[@MODULE[ModuleRTAntenna]:HAS[#DishAngle[*]]]:FINAL

So the final patch would be:

@PART[*]:HAS[@MODULE[ModuleRTAntenna]:HAS[#DishAngle[*]]]:FINAL
{
	@MODULE[ModuleRTAntenna]
	{
		@EnergyCost *= 0.50
	}
}

 

Edited by Tivec
Found the solution!
Link to comment
Share on other sites

10 minutes ago, Tivec said:

Hello!

I'm trying to write a patch that modifies the energy usage on RemoteTech2 dishes.

This is what I have. However, this also applies to the omnidirectional antennae from the same mod. How would I go about filtering for only the dishes?

Omni antennae look like this:

Dishes look like this:

My first thought was to try to filter on DishAngle, but sadly that's where my skill with MM ends. Any help is appreciated.

you pasted 2 dishes as opposed as 1 omni and 1 dish

Link to comment
Share on other sites

Just now, Tivec said:

Fixed it, and found the solution as well :)

@PART:FINAL
{
	@MODULE[ModuleRTAntenna]:HAS[#DishAngle[*]]
	{
		@EnergyCost *= 0.50
	}
}

I would go with this one, it's a bit cleaner and less likely to break on weird parts

Link to comment
Share on other sites

Just now, Sigma88 said:

@PART:FINAL
{
	@MODULE[ModuleRTAntenna]:HAS[#DishAngle[*]]
	{
		@EnergyCost *= 0.50
	}
}

I would go with this one, it's a bit cleaner and less likely to break on weird parts

Thank you, I will give that a look. Don't I need a :HAS[ModuleRTAntenna] though? Or will that find that module anywhere in the part hierarchy?

Link to comment
Share on other sites

Just now, Tivec said:

Thank you, I will give that a look. Don't I need a :HAS[ModuleRTAntenna] though? Or will that find that module anywhere in the part hierarchy?

if the patch doesn't find a MODULE that fits this line:

@MODULE[ModuleRTAntenna]:HAS[#DishAngle[*]]

it will just do nothing

Link to comment
Share on other sites

On 18/7/2017 at 7:06 AM, Aelfhe1m said:

It' should be in the main game log. Just search for "[ModuleManager] Error".

THANK YOU!
... found the error at first try, after your hint...
(Note for myself: remember always to close any parenthesis opened in a part list :P )

Edited by Araym
Link to comment
Share on other sites

Spoiler
On 15.7.2017 at 11:57 AM, KerbMav said:

I want to add something at the end of a key, specifically resources to a FuelSwitch config.



@PART[*]:HAS[@RESOURCE[Ore],#category[FuelTank],MODULE[InterstellarFuelSwitch],!MODULE[ProceduralPart]]:AFTER[SimpleConstruction] {
	@MODULE[InterstellarFuelSwitch]
	{
		@resourceGui = Ore;Metal;RocketParts;Uraninite;rich.Uranium;depl.Uranium
		@resourceNames = Ore;Metal;RocketParts;Uraninite;EnrichedUranium;DepletedUranium
		@resourceAmounts = #$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$
	}
}

But without reusing the full lines.
I am currently guessing:



@resourceGui = #$resourceGui$;Uraninite;rich.Uranium;depl.Uranium
@resourceNames = #$resourceNames$;Uraninite;EnrichedUranium;DepletedUranium
@resourceAmounts = #$resourceAmounts$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$

Also, can I write all this in one single line to comment it out all at once like so?



// @resourceGui = #$resourceGui$;Uraninite;rich.Uranium;depl.Uranium @resourceNames = #$resourceNames$;Uraninite;EnrichedUranium;DepletedUranium @resourceAmounts = #$resourceAmounts$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$

Or would I have to use some kind of divider/are the line breaks necessary?

No insight anybody?

 

Edited by KerbMav
Link to comment
Share on other sites

1 hour ago, KerbMav said:

No insight anybody?

Line breaks are essential. They (and comments) mark the end of each key value pair.

Your syntax looks about right although I'm not sure what you're trying to add since Uranite etc. are already in the first snippet (unless the first snippet is a combination of original patch plus desired changes)

Anyway here's a simplified test case I tried focusing just on modifying the lists:

Spoiler

DUMMYNODE
{
	RESOURCE
	{
		name = Ore
		maxAmount = 100
	}
	
	TESTOBJECT
	{
		labels = one;two;three
		values = 200;200;200
	}
}

@DUMMYNODE:FINAL
{
	@TESTOBJECT
	{
		@labels = #$labels$;four;five
		@values = #$values$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$
	}
}

and the result from ModuleManager.ConfigCache


DUMMYNODE
{
	RESOURCE
  	{
		name = Ore
		maxAmount = 100
  	}
	TESTOBJECT
	{
		labels = one;two;three;four;five
		values = 200;200;200;100;100
	}
}

 

 

Link to comment
Share on other sites

@Aelfhe1m Thank you!

I have to confess, I have been quite ignorant about the ModuleManager.ConfigCache - could have saved all of us some time. :D

Edit:

Config of the small ore tank as reference:

Spoiler

PART
{
name = SmallTank
module = Part
author = RoverDude

mesh = SmallTank.mu
scale = 1
rescaleFactor = 1

node_attach = 0,0,0.6,0,0,-1,1
node_stack_top = 0.0, .9, 0.0, 0.0, 1.0, 0.0, 1
node_stack_bottom = 0.0, -.9, 0.0, 0.0, -1.0, 0.0, 1


TechRequired = advScienceTech
entryCost = 3000
cost = 1000
category = FuelTank
subcategory = 0
title = #autoLOC_500673 //#autoLOC_500673 = Small Holding Tank
manufacturer = #autoLOC_501627 //#autoLOC_501627 = Jebediah Kerman's Junkyard and Spacecraft Parts Co
description = #autoLOC_500674 //#autoLOC_500674 = A small tank for storing raw materials, or possibly spare snacks.
attachRules = 1,1,1,1,0

// --- standard part parameters ---
mass = 0.50
dragModelType = default
maximum_drag = 0.2
minimum_drag = 0.2
angularDrag = 2
crashTolerance = 7
maxTemp = 2000 // = 3000
bulkheadProfiles = size1, srf
tags = #autoLOC_500675 //#autoLOC_500675 = black isru mine )mining (ore resource store
RESOURCE
{
    name = Ore
    amount = 0
    maxAmount = 300
}

MODULE
{
    name = ModuleFuelJettison
}


}

 

OreTanksSwitch.cfg from Simple Construction

Spoiler

@PART[*]:HAS[@RESOURCE[Ore],#category[FuelTank],!MODULE[InterstellarFuelSwitch],!MODULE[ProceduralPart]]:NEEDS[InterstellarFuelSwitch] {
    MODULE
    {
        name = InterstellarFuelSwitch
        resourceNames = Ore;Metal;RocketParts
        resourceAmounts = #$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$
        @resourceAmounts[2,;] *= 2
        tankMass = #$../mass$
        basePartMass = 0.0
        displayCurrentTankCost = true
        hasGUI = true
        availableInFlight = true
        availableInEditor = true
        showInfo = true
    }
}

My attempt to add three more resources to the tanks:

Spoiler

@PART[*]:HAS[@RESOURCE[Ore],#category[FuelTank],@MODULE[InterstellarFuelSwitch],!MODULE[ProceduralPart]]:FINAL
{
    @MODULE[InterstellarFuelSwitch]
    {
        @resourceGui = #$resourceGui$;Uraninite;rich.Uranium;depl.Uranium
        @resourceNames = #$resourceNames$;Uraninite;EnrichedUranium;DepletedUranium
        @resourceAmounts = #$resourceAmounts$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$;$../RESOURCE[Ore]/maxAmount$
    }
}

Somewhere I must have made a mistake, as it is not working as desired.

Shameful Edit

@PART[*]:HAS[@RESOURCE[Ore],#category[FuelTank],@MODULE[InterstellarFuelSwitch], ...

AAAARRGGHHH!!!

Edited by KerbMav
Link to comment
Share on other sites

3 hours ago, Trekkie148 said:

I use this addon a lot but it glitches out the solar panels in the game a lot. I need help and soon please? and a fixed download

It doesn't glitch your solar panels. But maybe you have a Module Manager patch that is changing your solar panels. It's not going to be possible for anyone to help you though without a lot more information: detailed description of the problem, log files (uploaded to an appropriate site such as Dropbox) and maybe your ModuleManager.ConfigCache file.

Link to comment
Share on other sites

55 minutes ago, Trekkie148 said:

The tab does not appear

Did you try with only mm installed or did you dump a gazilion mods in gamedata and then picked one at random to blame?

Edited by Sigma88
Link to comment
Share on other sites

How do I target and double a value in a key if there are many?

keyA = 100;100;100;100;100

Is there a way to change the third value to be double?

keyA= 100;100;200;100;100

Also, can I target it depending on another key?

keyB = AAA;BBB;CCC;DDD;EEE
keyA = 100;100;100;100;100

So, check position of CCC and double value in same position at keyA?

keyB = AAA;BBB;CCC;DDD;EEE
keyA = 100;100;200;100;100

And while we are at it, what if I wanted to change CCC afterwards into FFF?

Edited by KerbMav
Link to comment
Share on other sites

@KerbMav 

keyA[0,;] to target the first element of keyA... keyA[1,;] to target the second element. Usually it would be keyA[0] but your delimiter is a semicolon so it's keyA[0,;] (see the comma followed by semicolon? to signalize that a semicolon is the delimiter being used)

 

Link to comment
Share on other sites

3 hours ago, KerbMav said:

can I target it depending on another key?


keyB = AAA;BBB;CCC;DDD;EEE
keyA = 100;100;100;100;100

So, check position of CCC and double value in same position at keyA?

no and yes

no you can't check the position of CCC

yes you can get to the result you want,

what you need to do is check if the first element is CCC 

if not, move the first element from each list at the end and loop the patch

when the first element is CCC you edit the value on the second list

then you keep moving elements at the end untill you have done a full "lap"

 

it's a lot complicated, so unless you know what you're doing with MM I'd advise against it

 

Link to comment
Share on other sites

1 hour ago, Sigma88 said:

unless you know what you're doing with MM I'd advise against it

... ... ... naaaahh ... :D

I get what you are saying, but I would have no clue how to do it in MM - I am still forgetting (after all these years) basic syntax and stuff, having to compare to old working patches whenever I start something new, so I really shouldn't get into this. :)

@Starwaster made my work a lot easier though.

@PART[*]:HAS[@MODULE[FSfuelSwitch]:HAS[#resourceNames[MetallicOre;Uraninite;Substrate;Minerals;Karbonite;ExoticMinerals,RareMetals;MaterialKits;Metals;Polymers;Supplies;Ore;Machinery;Recyclables;SpecializedParts;Fertilizer;Hydrates;Gypsum;Dirt;Silicates;Silicon;RefinedExotics;ColonySupplies;Organics;Rock]]]
{
	@MODULE[FStextureSwitch2]
	{
		@textureDisplayNames[7,;] = Metal
		@textureDisplayNames[13,;] = RocketParts
	}
	
	@MODULE[FSfuelSwitch]
	{
		@resourceNames[7,;] = Metal
		@resourceNames[13,;] = RocketParts
	}	
}

//  0 MetallicOre
//  1 Uraninite
//  2 Substrate
//  3 Minerals
//  4 Karbonite
//  5 ExoticMinerals,RareMetals
//  6 MaterialKits
//  7 Metals
//  8 Polymers
//  9 Supplies
// 10 Ore
// 11 Machinery
// 12 Recyclables
// 13 SpecializedParts
// 14 Fertilizer
// 15 Hydrates
// 16 Gypsum
// 17 Dirt
// 18 Silicates
// 19 Silicon
// 20 RefinedExotics
// 21 ColonySupplies
// 22 Organics
// 23 Rock

My next problem deals with editing all values in a key at once.

tankCost = 225280;89600;38400;102400;40960;19200000;256000;1822720;1024000;320000;512;2022400;896000;4096000;256000;64000;1280;38400;1280;2560;32000000;1920000;64000;64000
basePartMass = 16
@tankCost,*[1,;] = #$basePartMass$
@tankCost[*] *= 5000

It does something, but I am getting negative values and values that shouldn't be there.

I have difficulties wrapping my head around Sarbians explanation. Some of these seem to be the same - at least for my limited understanding of code magic.

@key,* = xxx
applies to all presents key value

@key[1] += 1
will apply the math to the 2nd component in a comma separated vector.
"key = 0,1,0,1" will be " key = 0,2,0,1"

@key[*] += 1
will add 1 to all elements of the vector.
"key = 1,2,3,4" will be changed to "key = 2,3,4,5"

@key,*[1, ] += 1
will do it on all the key

 

Edited by KerbMav
Link to comment
Share on other sites

26 minutes ago, KerbMav said:

I have difficulties wrapping my head around Sarbians explanation. Some of these seem to be the same - at least for my limited understanding of code magic.

I think part of what confused me in these examples to begin with is that it's mixing two types of indexing. The first example is about modifying multiple lines that all have the same key name

key = value1
key = value2
key = value3

Then the next two lines are about modifying specific parts of a single line with multiple values (sarbian calls this a vector in the explanations following each example which to me were clear enough)

Finally the last example does both and just to make things more unobvious is doing it on a set of space separated vectors (without actually mentioning thats what the comma space in the brackets is for)

key = value1 value2 value3
key = value4 value5 value6
key = value7 value8 value9

 

Link to comment
Share on other sites

Turns out my patch works just fine (now, after already forgetting what Starwaster told me).

@tankCost[*,;] = 5000
@tankCost[*,;] *= #$basePartMass$

But FSfuelSwitch must do something else that kerbs it afterwards.

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