Jump to content

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


sarbian

Recommended Posts

Aha, but I can do:

@PART:HAS[@MODULE[ModuleGenerator]:HAS[@OUTPUT_RESOURCE:HAS[~name[ElectricCharge]]]]:LAST[CAMREC] {
  %tags ^= :$: CAMRECnotRTG:
}
@PART:HAS[@MODULE[ModuleGenerator]:HAS[!INPUT_RESOURCE,@OUTPUT_RESOURCE[ElectricCharge]:HAS[#rate[>0]]],~tags[*CAMRECnotRTG*]]:LAST[CAMREC] {
  @description ^= :$: CAMREC RTG buff.:
  @MODULE[ModuleGenerator] {
    @OUTPUT_RESOURCE[ElectricCharge] {
      @rate *= 3
    }
  }
}

and that _does_ cut out the modified RTG that makes LF. Thanks.

Link to comment
Share on other sites

20 hours ago, blowfish said:

Check your brackets here, I'll look at the other one later.

Gah, this is like being a LISP programmer. However, removing the extra square brackets doesn't make a difference.

Sorry, I wrote that in a hurry. To be more clear:

@PART:HAS[@MODULE[ModuleGenerator]:HAS[!INPUT_RESOURCE,@OUTPUT_RESOURCE[ElectricCharge]:HAS[#rate[>0]]],!OUTPUT_RESOURCE:HAS[~name[ElectricCharge]]]:LAST[CAMREC] {


does select an RTG that outputs LF.

Edited by damerell
Link to comment
Share on other sites

  • 1 month later...
5 hours ago, toric5 said:

What would be the simplest way to apply a patch to all modules of a given type?

https://forum.kerbalspaceprogram.com/index.php?/topic/196855-campaign-for-real-electriccharge/ may prove useful. I have been tangling with MM seriously for the first time, and most of what I want to do there is apply a patch to all objects of a given type.

http://www.chiark.greenend.org.uk/~damerell/games/ksp/CAMREC/CAMREC.cfg is the actual MM file buried in the walls of text.

Link to comment
Share on other sites

8 hours ago, damerell said:

https://forum.kerbalspaceprogram.com/index.php?/topic/196855-campaign-for-real-electriccharge/ may prove useful. I have been tangling with MM seriously for the first time, and most of what I want to do there is apply a patch to all objects of a given type.

http://www.chiark.greenend.org.uk/~damerell/games/ksp/CAMREC/CAMREC.cfg is the actual MM file buried in the walls of text.

I dont think this will apply to a single part with multiple modules of the same type.

Link to comment
Share on other sites

On 2/16/2016 at 3:52 PM, sarbian said:

Ok, new features time. v2.619

1. "MM_PATCH_LOOP {}" nodes. They will have the current node loop on the active top node until the HAS condition is not valid anymore. It has some really specific use from complex patch and can easily lead to infinite loops.

A patch that would remove all ressource of all PART (of course there are easier way to do that)


@PART[*]:HAS[@RESOURCE[*]]
{
	!RESOURCE,0 {}
	
	MM_PATCH_LOOP {}
}

 

what is the simpler way to do this if you dont know how many resources a part has? Im trying to apply a patch to multiple modules of the same type in the same part, but this patch will apply to multiple parts with different numbers of nodes each.

Link to comment
Share on other sites

On 11/21/2020 at 12:51 PM, toric5 said:

what is the simpler way to do this if you dont know how many resources a part has? Im trying to apply a patch to multiple modules of the same type in the same part, but this patch will apply to multiple parts with different numbers of nodes each.

Not sure what you're asking.  In the quoted patch, it will target any PART with at least one RESOURCE, and remove the first RESOURCE node, repeatedly (because of the loop), until the original condition (has at least one RESOURCE node) is no longer true.

Note in this instance there's actually a way to do it without the loop: !RESOURCE,* {} will remove all RESOURCE nodes at once so no need to loop, but loops are useful in other scenarios.

Link to comment
Share on other sites

7 hours ago, blowfish said:

Not sure what you're asking.  In the quoted patch, it will target any PART with at least one RESOURCE, and remove the first RESOURCE node, repeatedly (because of the loop), until the original condition (has at least one RESOURCE node) is no longer true.

Note in this instance there's actually a way to do it without the loop: !RESOURCE,* {} will remove all RESOURCE nodes at once so no need to loop, but loops are useful in other scenarios.

ok, to be more specific, Im trying to write a patch along the lines of:

@PART[*]:HAS[@MODULE[ModuleresourceConverter]]:FOR[SystemHeat]:FINAL {

	@MODULE[ModuleResourceConverter]{
		@name = ModuleSystemHeatConverter
		//other stuff
	}
}

However, to my understanding, the above will only change the first ModuleResourceConverter into a ModuleSystemHeatConverter.

If I understand your post correctly,

@MODULE[ModuleResourceConverter], * {

will make the patch apply to each ModuleResourceConverter in a part?

Link to comment
Share on other sites

So im installing this cause Astronomer's Visual Pack demands it, but I am a bit confussed as to what I need to install am I just throwing the .dll in the gamedata folder like my other mods? Sorry for the stupid question long time player first time ksp modder.

Edit - Sorry missed the bit at the bottom of the first post.

Edited by Nexxus88
Link to comment
Share on other sites

I'll want following tags:

:IF(like :NEEDS, but checks its parent)

Conditional code within #IF[] and #ENDIF

SubSections:

  • #DO - unconditional single
  • #LOOP - unconditional loop
  • #IF[] - conditional single
  • #WHILE[] - conditional loop
  • #END - end
  • #REIF[] - conditional retry
  • #RE - unconditional retry
  • #BREAK - unconditional break
  • #BIF[] - conditional break

Full sections:

  • #KALL - stop all runs of given patch
  • #KTHIS - stop this run of patch
  • #RETRY - re-run this copy of patch
  • #REALL - re-run all copies of this patch

Use #COND[] to set conditions on following operations using question mark. To prevent hacking, the value should be reset to false before going to next file.

Functions:

  • #LOG = - print x in KSP.log
  • #TYPE = - change node's type
  • #IFVAR = - use variable as condition

It will need new method of operation:

  1. Tokenize all CFGs
  2. Convert all scripts into executable code
  3. Reorder scripts based on order tags and file names
  4. Run scripts in order

I plan to use these in SSTO Framework, part of SSTO Project Core

 

Link to comment
Share on other sites

So im trying to get comfortable with the variable sytax, but I seem to be running into a bit of a snag when they are used in key-value curves. I have this patch:

@PART[*]:HAS[@MODULE[ModuleResourceConverter]:HAS[@INPUT_RESOURCE:HAS[#ResourceName[ElectricCharge]]]]:FINAL{ //really need final.
	!MODULE[ModuleCoreHeat] {}
	%MODULE[ModuleSystemHeat]
	{
		%name = ModuleSystemHeat
		// Cubic metres
		%volume = #$/mass$ //1 ton equals 1 cubic meter of cooling. it *very roughly* approximates the balance of squads ISRU
		%moduleID = isru
		%iconName = Icon_Gears
	}

	!MODULE[ModuleOverheatDisplay]{}

	@MODULE[ModuleResourceConverter]:HAS[@INPUT_RESOURCE:HAS[#ResourceName[ElectricCharge]]]{ //Ive seen some converters that dont use electric charge, those things need thier own patch, as we calculate produced heat based on EC consumption.
		@name = ModuleSystemHeatConverter
		moduleID = #$ConverterName$ //this should be the localization string or the actual name, either way, unique.
		systemHeatModuleID = isru
		shutdownTemperature = 800
		systemOutletTemperature = 600 // temp for freeing water from hydrate regolith. other values could be: 400k for production of hydrazine, 5-600k for decomposition of hydrates, 700 for sabatier process, 373-1000k for high temp electrolysis of water.
		systemEfficiency
		{
			key = 0 0.0
			key = 300 1.0
			key = 1000 1.0
			key = 1300 0.0
		}
		systemPower
		{
			key = 0 #$INPUT_RESOURCE[ElectricCharge]/Ratio$ //set the heat ouput as proportional to the EC usage. TODO: figure out what ratio to use.
		}
		!Thermalefficiency {}
		!TemperatureModifier {}
		@generatesHeat = false //disable stock heating
	}
}

and almost everthing seems to work, exept for the systemPower node. It seems like MM is not parsing the variable syntax and inserting this directly into the config, so I get things like this in my mm config cache.

			systemPower
			{
				key = 0 #$INPUT_RESOURCE[ElectricCharge]/Ratio$
			}

Do I have some error in the patch? is what I am doing even supported?

Link to comment
Share on other sites

9 hours ago, toric5 said:

			systemPower
			{
				key = 0 #$INPUT_RESOURCE[ElectricCharge]/Ratio$
			}

Do I have some error in the patch? is what I am doing even supported?

the # goes before the 0.  The # tells MM that there are interpolations, the actual interpolations themselves are bounded by $ signs

Link to comment
Share on other sites

1 hour ago, blowfish said:

the # goes before the 0.  The # tells MM that there are interpolations, the actual interpolations themselves are bounded by $ signs

ah. I thought the # came just before the variable. Ill test it later today.

Link to comment
Share on other sites

On 12/2/2020 at 11:59 AM, blowfish said:

the # goes before the 0.  The # tells MM that there are interpolations, the actual interpolations themselves are bounded by $ signs

from my modulemanager.log:

Error - Cannot parse variable search when inserting new key key = #0 $INPUT_RESOURCE[ElectricCharge]/Ratio$

to be clear,

{
			key = #0 $INPUT_RESOURCE[ElectricCharge]/Ratio$ //set the heat ouput as proportional to the EC usage. TODO: figure out what ratio to use.
}

is editing a curve with only one key.

Edited by toric5
Link to comment
Share on other sites

6 hours ago, toric5 said:

from my modulemanager.log:

Error - Cannot parse variable search when inserting new key key = #0 $INPUT_RESOURCE[ElectricCharge]/Ratio$

to be clear,




{
			key = #0 $INPUT_RESOURCE[ElectricCharge]/Ratio$ //set the heat ouput as proportional to the EC usage. TODO: figure out what ratio to use.
}

is editing a curve with only one key.

@toric5, ignore the earlier comment, didn't read the entire patch

Edited by hemeac
Incorrect advice
Link to comment
Share on other sites

6 hours ago, toric5 said:

from my modulemanager.log:

Error - Cannot parse variable search when inserting new key key = #0 $INPUT_RESOURCE[ElectricCharge]/Ratio$

to be clear,


{
			key = #0 $INPUT_RESOURCE[ElectricCharge]/Ratio$ //set the heat ouput as proportional to the EC usage. TODO: figure out what ratio to use.
}

is editing a curve with only one key.

It's only going to look in that node.  If you want to look up a level, you need ../INPUT_RESOURCE, or ../../INPUT_RESOURCE for two levels, etc

Link to comment
Share on other sites

3 hours ago, blowfish said:

It's only going to look in that node.  If you want to look up a level, you need ../INPUT_RESOURCE, or ../../INPUT_RESOURCE for two levels, etc

I want to look down a node. so, the parts in question have a ModuleResourceConverter, each of which contain INPUT_RESOURCE subnodes. I am trying to patch the ModuleResourceConverter to a ModuleSystemHeatConverter, which extends ModuleResourceConverter and needs a few new config values. The only value Im having trouble with is setting the systemPower (the modules heat output) to be a fraction of the parts EC consumption.

 

for reference, here is the config for the squad ISRU, which would be targeted by this patch.

PART
{
name = ISRU
module = Part
author = RoverDude

mesh = ISRU.mu
scale = 1
rescaleFactor = 1

node_stack_top = 0.0, 1.5, 0.0, 0.0, 1.0, 0.0, 2
node_stack_bottom = 0.0, -1.5, 0.0, 0.0, -1.0, 0.0, 2

TechRequired = advScienceTech
entryCost = 24000
cost = 8000
category = Utility
subcategory = 0
title = #autoLOC_500652 //#autoLOC_500652 = Convert-O-Tron 250
manufacturer = #autoLOC_501638 //#autoLOC_501638 = Kerbodyne
description = #autoLOC_500653 //#autoLOC_500653 = This mobile processing plant can take raw materials containing even trace amounts of oxygen and hydrogen, and crack them into useful fuel products.  When operated by a skilled engineer, you will be able to operate with better efficiency.  These modules operate best at their ideal operating temperatures, and features auto-shutdown in the event of excessive overheating.  Radiators can be used to help manage excessive heat.
attachRules = 1,1,1,0,0

// --- standard part parameters ---
mass = 4.25
dragModelType = default
maximum_drag = 0.2
minimum_drag = 0.2
angularDrag = 2
crashTolerance = 7
maxTemp = 2000 // = 3500
bulkheadProfiles = size2, srf
tags = #autoLOC_500654 //#autoLOC_500654 = conver isru mine )mining (ore process resource
	MODULE
	{
		name = ModuleOverheatDisplay
	}

	MODULE
	{
		 name = ModuleResourceConverter
		 ConverterName = #autoLOC_502026 //#autoLOC_502026 = Lf+Ox
		 StartActionName = #autoLOC_502027 //#autoLOC_502027 = Start ISRU [Lf+Ox]
		 StopActionName = #autoLOC_502028 //#autoLOC_502028 = Stop ISRU [Lf+Ox]
		AutoShutdown = true
		TemperatureModifier
		{
			key = 0 100000
			key = 750 50000
			key = 1000 10000
			key = 1250 500	
			key = 2000 50	
			key = 4000 0
		}				
		GeneratesHeat = true
		DefaultShutoffTemp = .8
		ThermalEfficiency 
		{
			key = 0 0 0 0
			key = 500 0.1 0 0
			key = 1000 1.0 0 0
			key = 1250 0.1 0 0
			key = 3000 0 0 0 
		}


		UseSpecialistBonus = true
		SpecialistEfficiencyFactor = 0.2
		SpecialistBonusBase = 0.05
		UseSpecialistHeatBonus = true
		SpecialistHeatFactor = 0.1
		ExperienceEffect = ConverterSkill
		EfficiencyBonus = 1
		resourceOutputName = #autoLOC_8012033		// #autoLOC_8012033 = LF+Ox

		 
		 INPUT_RESOURCE
		 {
			ResourceName = Ore
			Ratio = 0.5
			FlowMode = STAGE_PRIORITY_FLOW
  		 }
		 INPUT_RESOURCE
		 {
			ResourceName = ElectricCharge
			Ratio = 30
		 }
		 OUTPUT_RESOURCE
		 {
			ResourceName = LiquidFuel
			Ratio = 0.45
			DumpExcess = false
			FlowMode = STAGE_PRIORITY_FLOW
		 }
		 OUTPUT_RESOURCE
		 {
			ResourceName = Oxidizer
			Ratio = 0.55
			DumpExcess = false
			FlowMode = STAGE_PRIORITY_FLOW
		 }
	}

	MODULE
	{
		 name = ModuleResourceConverter
		 ConverterName = #autoLOC_502029 //#autoLOC_502029 = Monoprop
		 StartActionName = #autoLOC_502030 //#autoLOC_502030 = Start ISRU [Monoprop]
		 StopActionName = #autoLOC_502031 //#autoLOC_502031 = Stop ISRU [Monoprop]
		AutoShutdown = true
		TemperatureModifier
		{
			key = 0 100000
			key = 750 50000
			key = 1000 10000
			key = 1250 500	
			key = 2000 50	
			key = 4000 0
		}				
		GeneratesHeat = true
		DefaultShutoffTemp = .8
		ThermalEfficiency 
		{
			key = 0 0 0 0
			key = 500 0.1 0 0
			key = 1000 1.0 0 0
			key = 1250 0.1 0 0
			key = 3000 0 0 0 
		}

		UseSpecialistBonus = true
		SpecialistEfficiencyFactor = 0.2
		SpecialistBonusBase = 0.05
		UseSpecialistHeatBonus = true
		SpecialistHeatFactor = 0.1
		ExperienceEffect = ConverterSkill
		EfficiencyBonus = 1
		resourceOutputName = #autoLOC_8012026		// #autoLOC_8012026 = Monoprop

		 
		 INPUT_RESOURCE
		 {
			ResourceName = Ore
			Ratio = 0.5
		 }
		 INPUT_RESOURCE
		 {
			ResourceName = ElectricCharge
			Ratio = 30
		 }
		 OUTPUT_RESOURCE
		 {
			ResourceName = MonoPropellant
			Ratio = 1
			DumpExcess = false
		 }
	}


	MODULE
	{
		 name = ModuleResourceConverter
		 ConverterName = #autoLOC_502032 //#autoLOC_502032 = LiquidFuel
		 StartActionName = #autoLOC_502033 //#autoLOC_502033 = Start ISRU [LqdFuel]
		 StopActionName = #autoLOC_502034 //#autoLOC_502034 = Stop ISRU [LqdFuel]
		AutoShutdown = true
		TemperatureModifier
		{
			key = 0 100000
			key = 750 50000
			key = 1000 10000
			key = 1250 500	
			key = 2000 50	
			key = 4000 0
		}				
		GeneratesHeat = true
		DefaultShutoffTemp = .8
		ThermalEfficiency 
		{
			key = 0 0 0 0
			key = 500 0.1 0 0
			key = 1000 1.0 0 0
			key = 1250 0.1 0 0
			key = 3000 0 0 0 
		}
		
		UseSpecialistBonus = true
		SpecialistEfficiencyFactor = 0.2
		SpecialistBonusBase = 0.05
		UseSpecialistHeatBonus = true
		SpecialistHeatFactor = 0.1
		ExperienceEffect = ConverterSkill
		EfficiencyBonus = 1
		resourceOutputName = #autoLOC_8012032		// #autoLOC_8012032 = LqdFuel

		 
		 INPUT_RESOURCE
		 {
			ResourceName = Ore
			Ratio = 0.45
			FlowMode = STAGE_PRIORITY_FLOW
  		 }
		 INPUT_RESOURCE
		 {
			ResourceName = ElectricCharge
			Ratio = 30
		 }
		 OUTPUT_RESOURCE
		 {
			ResourceName = LiquidFuel
			Ratio = 0.9
			DumpExcess = false
			FlowMode = STAGE_PRIORITY_FLOW
		 }
	}

	
	MODULE
	{
		 name = ModuleResourceConverter
		 ConverterName = #autoLOC_502035 //#autoLOC_502035 = Oxidizer
		 StartActionName = #autoLOC_502036 //#autoLOC_502036 = Start ISRU [Ox]
		 StopActionName = #autoLOC_502037 //#autoLOC_502037 = Stop ISRU [Ox]
		AutoShutdown = true
		TemperatureModifier
		{
			key = 0 100000 0 0
			key = 750 50000 0 0
			key = 1000 10000 0 0
			key = 1250 500 0 0	 
			key = 2000 50 0 0	
			key = 4000 0 0 0
		}				
		GeneratesHeat = true
		DefaultShutoffTemp = .8
		ThermalEfficiency 
		{
			key = 0 0 0 0
			key = 500 0.1 0 0
			key = 1000 1.0 0 0
			key = 1250 0.1 0 0
			key = 3000 0 0 0 
		}

		UseSpecialistBonus = true
		SpecialistEfficiencyFactor = 0.2
		SpecialistBonusBase = 0.05
		UseSpecialistHeatBonus = true
		SpecialistHeatFactor = 0.1
		ExperienceEffect = ConverterSkill
		resourceOutputName = #autoLOC_8012027		// #autoLOC_8012027 = Ox

		EfficiencyBonus = 1

		 
		 INPUT_RESOURCE
		 {
			ResourceName = Ore
			Ratio = 0.55
			FlowMode = STAGE_PRIORITY_FLOW
  		 }
		 INPUT_RESOURCE
		 {
			ResourceName = ElectricCharge
			Ratio = 30
		 }
		 OUTPUT_RESOURCE
		 {
			ResourceName = Oxidizer
			Ratio = 1.1
			DumpExcess = false
			FlowMode = STAGE_PRIORITY_FLOW
		 }
	}
	
	MODULE
	{
		name = ModuleAnimationGroup
		deployAnimationName = 
		activeAnimationName = ProcessorLarge_running
		deployActionName = #autoLOC_6002380 //#autoLOC_6002380 = Deploy <<1>>
		retractActionName = #autoLOC_6002381 //#autoLOC_6002381 = Retract <<1>>
		toggleActionName = #autoLOC_6002382 //#autoLOC_6002382 = Toggle <<1>>
		moduleType = #autoLOC_7001227  //Converter //#autoLOC_7001227 = Converter
		autoDeploy = true
	}
	

	MODULE
	{
		name = ModuleCoreHeat
		CoreTempGoal = 1000					//Internal temp goal - we don't transfer till we hit this point
		CoreToPartRatio = 0.1				//Scale back cooling if the part is this % of core temp
		CoreTempGoalAdjustment = 0			//Dynamic goal adjustment
		CoreEnergyMultiplier = 0.1			//What percentage of our core energy do we transfer to the part
		HeatRadiantMultiplier = 0.05		//If the core is hotter, how much heat radiates?
		CoolingRadiantMultiplier = 0		//If the core is colder, how much radiates?
		HeatTransferMultiplier = 0			//If the part is hotter, how much heat transfers in?
		CoolantTransferMultiplier = 0.01	//If the part is colder, how much of our energy can we transfer?
		radiatorCoolingFactor = 1			//How much energy we pull from core with an active radiator?  >= 1
		radiatorHeatingFactor = 0.05		//How much energy we push to the active radiator
		MaxCalculationWarp = 1000			//Based on how dramatic the changes are, this is the max rate of change
		CoreShutdownTemp = 4000				//At what core temperature do we shut down all generators on this part?
		MaxCoolant = 200					//Maximum amount of radiator capacity we can consume - 50 = 1 small
	}

}

as you can see, INPUT_RESOURCE is a child node of ModuleResourceConverter.

Link to comment
Share on other sites

9 minutes ago, toric5 said:

I want to look down a node. so, the parts in question have a ModuleResourceConverter, each of which contain INPUT_RESOURCE subnodes. I am trying to patch the ModuleResourceConverter to a ModuleSystemHeatConverter, which extends ModuleResourceConverter and needs a few new config values. The only value Im having trouble with is setting the systemPower (the modules heat output) to be a fraction of the parts EC consumption.

for reference, here is the config for the squad ISRU, which would be targeted by this patch.

as you can see, INPUT_RESOURCE is a child node of ModuleResourceConverter.

The key you're trying to set is in systemPower, which means systemPower is the current node it's going to look at.

E: to be clear, the exact syntax you want is key = #0 $../INPUT_RESOURCE[ElectricCharge]/Ratio$, should have noticed that in the original question

Edited by blowfish
Link to comment
Share on other sites

12 hours ago, blowfish said:

The key you're trying to set is in systemPower, which means systemPower is the current node it's going to look at.

E: to be clear, the exact syntax you want is key = #0 $../INPUT_RESOURCE[ElectricCharge]/Ratio$, should have noticed that in the original question

... im dumb. should have done more rubber duck debugging.

Link to comment
Share on other sites

  • 2 weeks later...

Just FYI, this is working fine in my install on 1.11.  It's a dependency of Kopernicus on CKAN, obviously, and it would be nice to update the metadata to indicate this if you feel it's ready, to ease installers on that platform to getting Kopernicus. 

This is not a "when'll it be ready?" post.  Just a heads up as to my experience with it, you should test yourself obviously and at your leisure @sarbian

PS:  Same story with ModularFlightIntegrator, though see Github for some interesting points there.

Edited by R-T-B
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...