Jump to content

Module manager exampels


maculator

Recommended Posts

Collection of exampels for module manager

"Why do I have to perform some experiments multiple times at the same location to max out my sciencegain?"

When I asked me this question the Xth time, I started looking arround for a solution, and I found it: module manager.

This neat little "plugin" allows you to write custom patches to change the behaviour of parts and some mechanics of KSP.

With the help of the official Handbook I figured out a way to achieve my goal: 

Spoiler

The code:

Spoiler

    @EXPERIMENT_DEFINITION[*]
    {
        %baseValue = #$scienceCap$
    }

What the code does ingame:

Spoiler

The "green" bar in the experiment window is usally filled a third, requiering you to visit the place again and redo the experiment. Now its always full, giving you 100% of the possible science the first time you execute it:

eoEL4pb.png

And this is how it works:
 

Spoiler

It searches for all Experimen_Definitions (there are 11 in total) and edits them. More specific it adds/edits the baseValue (wich defines the science you get for a single execution) and matches it with the scienceCap (wich defines the total ammount of science this experiment can give you) via copying the value of scienceCap.

 

Now, even this is a verry simple patch, it took me quite a while and some help from the community to figure it all out.

So I thought for people like me I just post a few things I've done so far and just hope some others do the same to help everyone who wants to learn how to make custom patches.

Here is another thing I did:

Spoiler

The code:

Spoiler

    @PART[*]:HAS[#category[Science],!MODULE[ModuleScienceLab],!MODULE[ModuleResourceScanner],!MODULE[ModuleOrbitalSurveyor],!MODULE[ModuleDataTransmitter]]:FINAL
    {
        %TechRequired = start
    }

What it does ingame:

Spoiler

It gives you all the experiments (thermometer, goo, seismic sensor,...) right at the start of your career.

The code:

Spoiler

It searches for all the parts that have the category science defined in their node. While doing so, it also makes sure the parts it finds don't have several other modules. (antennas for exampel are also in the category science but I didn't want to have all the antennas at start unfortunaly antennas have a module for transmitting data, wich the experiments dont have) This leaves only the experiments, wich are then edited to be available at start.

 

If you need some help finding ideas or a parts name here are 2 usefull links:

A basic one Click Me! and a more detailed, advanced one Click Me!

 

It would be nice to see some things other people have done since thats what I'm looking for. So if you have something please share it (doesn't have to be a rainbow like mine)

 

 

So the "rainbowthing" might have been a bit too much.

However: IF you like to post some patches (and I hope you do) please do it in the following format:

Give the thing a title, make that title bold and and set the font size to 16, then make a spoiler and put the code inside the spoiler.

 

Awsome Example:

Spoiler

@THREAD[Module manager exampels]
{
	%Format = AWSOME
}

If you want to explain something write it here

 

 

 

Edited by maculator
Layout
Link to comment
Share on other sites

Do you end up hauling around monopropellant that you never use? Well, zap it from the start with this little MM patch.

Spoiler

@PART[*]:HAS[@MODULE[ModuleCommand],@RESOURCE[MonoPropellant]]
{
    @RESOURCE[MonoPropellant]
    
    {      
    %amount = 0      
    }
}

This will make it so that all your command pods start with empty monopropellant tanks.

Link to comment
Share on other sites

5 hours ago, Otis said:

Do you end up hauling around monopropellant that you never use? Well, zap it from the start with this little MM patch.

  Hide contents

@PART[*]:HAS[@MODULE[ModuleCommand],@RESOURCE[MonoPropellant]]
{
    @RESOURCE[MonoPropellant]
    
    {      
    %amount = 0      
    }
}

This will make it so that all your command pods start with empty monopropellant tanks.

This is a good example!

Because I have a question :) : why is it %amount = 0 wouldnt that make mm creat a amount = 0 even in probe cores since they too have a module command?

-___-  i didn't see the ,@RESOURCE[MonoPropellant] ... stupid me

 

Edit: Here is another one:

Decoupler integrated in Heatshields with description added to the stockdescription rather then overwriting it:

Spoiler

//Add decouplers to heatshields

	@PART[HeatShield*]:FINAL
	{
	
		sound_vent_large = decouple
		fx_gasBurst_white = 0.0, 0.0650517, 0.0, 0.0, 1.0, 0.0, decouplefx_gasBurst_white = 0.0, 0.0650517, 0.0, 0.0, 1.0, 0.0, decouple
		
		@description ^= :$:. Equiped with integrated decoupler and ultra cool "woosh"-effect! They'll know what hit 'em.:
	
		MODULE
		{
			name = ModuleDecouple
			ejectionForce = 40
			isOmniDecoupler = true
		}
	}

 

 

Edited by maculator
got it
Link to comment
Share on other sites

5 hours ago, maculator said:

So i thought I might share the stuff I created, as a beginner, with the community and make it nice and colorful.

AWESOME way to explain this!!...I've bookmarked this thread...

Thanx!! :D

Edited by Stone Blue
Link to comment
Share on other sites

So I might aswell post everything I did so far!

Want a part right at the start? (because not having some wheels anoys you, or you just want to have that mainsal engine for pure fun?)

Very basic part (wheel in this case) at start of career:

Spoiler

//Unlock a set of wheels for the start:

	@PART[roverWheel1]
	{
		%TechRequired = start
	}

 

Want to go "a bit" faster with your rover without having to change tires every time? (No engine included the power of the wheels stays the same, use rocketengine instead)

Spoiler

//No overspeeddamage for roverwheels:

	@PART[*]:HAS[@MODULE[ModuleWheel],!MODULE[ModuleLandingGear]]:FINAL
	{
	
		@description ^= :$: Finally featuring extra strong rims for high overland speeds without the need to carry a dozen sparewheels.:
		%PhysicsSignificance = 1
		
		@MODULE[ModuleWheel]
		{
			%impactTolerance = 1000
			%overSpeedDamage = 1000
		}
	}

for the @description it works like this: ^= means "at the end" ::: is for search between the first two : is the term it searches, in this case it searches everything because there is nothing inside exept the $ wich tells it to copy what it finds and between the secon and third : comes what you'd like to add, in this case a hopfully funny addon to the description. (I cant guarantee that this is 100% the way it works but it works^^) Tl;Dr: MAGIC!

Want mechjeb in all your pods because you dont want to add more parts? (also have all the functions available at the start -exept the ones wich unlock with facility upgrades-)

Spoiler

//Unlock MechJeb for all command-parts at start:

	@PART[*]:HAS[@MODULE[ModuleCommand]]:NEEDS[MechJeb2]:FINAL
	{		
		%MODULE[MechJebCore]
		{
			MechJebLocalSettings[*]
			{
				%unlockTechs = start
			}
		}
	}

With this you can also delete the "Parts" folder inside the "Mechjeb2" folder and save an INCREDIBLE ammount of ram.....

Also thanks to ":NEEDS[MechJeb2]" it'll only apply itself when mechjeb is installed.

and finally

More Power for your Launchclamps (So waiting in the night for a launchwindow wont drain your batterys):

Spoiler

//More electric power for launchclamps:

	@PART[*]:HAS[@MODULE[LaunchClamp]]
	{
		@MODULE[ModuleGenerator]
		{
			@OUTPUT_RESOURCE[ElectricCharge]
			{
				@rate = 100 //1 is normal
			}
		}
	}

 

If you didn't know: // indicates a comment and is irrelevant for the patch

Link to comment
Share on other sites

This could be very helpful for some people, but you should spell "examples" correctly in the thread title (may make it easier to find) and also not use cyan for text as it is very hard to read on a pale background.

Also, I'm not sure it should really be in this sub-forum as it isn't anything to do with developing plugins.  More people may find it in the main mod development sub-forum.

Edited by Padishar
Link to comment
Share on other sites

40 minutes ago, Padishar said:

This could be very helpful for some people, but you should spell "examples" correctly in the thread title (may make it easier to find) and also not use cyan for text as it is very hard to read on a pale background.

Also, I'm not sure it should really be in this sub-forum as it isn't anything to do with developing plugins.  More people may find it in the main mod development sub-forum.

Yep english is not my native language ...

I asked to move the thread thanks.

Link to comment
Share on other sites

Want to make a part bigger/smaller?

Spoiler

 


	$PART[launchClamp1]
	{
		@name = [launchClamp2]
		@rescaleFactor = 2
	}

Use $ to copy, rename the copy and alter its size via the rescaleFactor

should look like this for the example:

355k9k7.png

 

Edited by maculator
Link to comment
Share on other sites

Enable crewreports for the guys in the sciencelabs:

Spoiler

//enable Crewreports for scienclab

	@PART[Large_Crewed_Lab]
	{
		MODULE
		{
			name = ModuleScienceExperiment
			experimentID = crewReport
			experimentActionName = Crew Report
			resetActionName = Discard Crew Report
			reviewActionName = Review Report
			useStaging = False
			useActionGroups = True
			hideUIwhenUnavailable = True
			rerunnable = True
			xmitDataScalar = 1.0
			usageReqMaskInternal = 5
			usageReqMaskExternal = -1
		}
	}

Since the lab has no ModuleScienceExperiment there is no need for a @ or %. If written like above it will just creat those new lines

 

Link to comment
Share on other sites

I've few of my own :

Full throttle on the launchpad

Spoiler

@PHYSICSGLOBALS
{
   prelaunchDefaultThrottle = 1
}

 

Better range for Goo ant Small Lab

Spoiler

// Increase range of Lab
@PART[science_module]
{
    @MODULE[ModuleScienceExperiment]
    {
        @interactionRange = 3
    }
}

// Increase range of Goo
@PART[GooExperiment]
{
    @MODULE[ModuleScienceExperiment]
    {
        @interactionRange = 3
    }
}

 

Edited by Warzouz
Link to comment
Share on other sites

  • 1 month later...
On 1/14/2016 at 10:37 AM, maculator said:

Decoupler integrated in Heatshields with description added to the stockdescription rather then overwriting it:

 

  Hide contents



//Add decouplers to heatshields

	@PART[HeatShield*]:FINAL
	{
	
		sound_vent_large = decouple
		fx_gasBurst_white = 0.0, 0.0650517, 0.0, 0.0, 1.0, 0.0, decouplefx_gasBurst_white = 0.0, 0.0650517, 0.0, 0.0, 1.0, 0.0, decouple
		
		@description ^= :$:. Equiped with integrated decoupler and ultra cool "woosh"-effect! They'll know what hit 'em.:
	
		MODULE
		{
			name = ModuleDecouple
			ejectionForce = 40
			isOmniDecoupler = true
		}
	}

 

 

I'm not sure but I think that would make the heatshield separate on both sides. The stock separators (both sides) has that isOmniDecoupler option set to true but the decouplers have an explosiveNodeID.

Link to comment
Share on other sites

  • 3 weeks later...

Stock repeatable experiments set to full transmission efficiency

@PART[sensorAccelerometer]
{
	@MODULE[ModuleScienceExperiment]
	{
		@xmitDataScalar = 1.0
	}
}
@PART[sensorGravimeter]
{
	@MODULE[ModuleScienceExperiment]
	{
		@xmitDataScalar = 1.0
	}
}
@PART[sensorBarometer]
{
	@MODULE[ModuleScienceExperiment]
	{
		@xmitDataScalar = 1.0
	}
}
@PART[sensorThermometer]
{
	@MODULE[ModuleScienceExperiment]
	{
		@xmitDataScalar = 1.0
	}
}
@PART[InfraredTelescope]:NEEDS[AsteroidDay]
{
	@MODULE[ModuleScienceExperiment]
	{
		@xmitDataScalar = 1.0
	}
}

Hardcoded for the stock "envirosensor" experiments(plus the official AsteroidDay telescope, if present), I figure that this makes unmanned craft more viable, while still limiting the materials bay and goo pod to recovery on Kerbin. While it makes sense to have to recover physical objects to evaluate them, there is no reason to require the physical thermometer to evaluate the temperature I actually thought of several reasons while typing this, but none of them apply in KSP :sticktongue:

Link to comment
Share on other sites

  • 4 weeks later...

If you miss the Kerbodyne Adapter with fuel, here it is

Spoiler

$PART[Size3to2Adapter]
{
    %name = W_Size3to2FuelTank
    %TechRequired = largeVolumeContainment
    %entryCost = 20000
    %cost = 2300
    %category = FuelTank
    %subcategory = 0
    %title = Kerbodyne ADTP-2-3 Fuelled
    %description = This fuel tank is a variation of the adapter. It's used to bridge between Kerbodyne and Rockomax rocket bodies.
    %attachRules = 1,1,1,1,0
    %mass = 1.7
    %crashTolerance = 20
    %breakingForce = 400
    %breakingTorque = 400
    %maxTemp = 2000 // = 2900
    %emissiveConstant = 0.8
    %fuelCrossFeed = True
    RESOURCE
    {
        %name = LiquidFuel
        %amount = 1080
        %maxAmount = 1080
    }
    RESOURCE
    {
        %name = Oxidizer
        %amount = 1320
        %maxAmount = 1320
    }
}

And if you wand the short adapter for Kerbodyne, here it is (thus the 2.5 m adapter is not up to scale, but with offset it's fine.)

Spoiler

$PART[largeAdapter2]
{
    @name = W_largeAdapter3
    @rescaleFactor = 1.5
    @node_stack_top = 0.0, 0.1892163, 0.0, 0.0, 1.0, 0.0, 3
    @node_stack_bottom = 0.0, -0.1892163, 0.0, 0.0, -1.0, 0.0, 2
    @TechRequired = advConstruction
    @entryCost = 5000
    @cost = 800
    @title = Kerbodyne Brand Adapter 03
    @description = A shorter adapter from Kerbodyne, formed under similar circumstances to its big brother. Coated with spaceproof paint for maximum integrity.
    @manufacturer = Kerbodyne
    @mass = 0.2
    @breakingForce = 400
    @breakingTorque = 400
    @bulkheadProfiles = size3, size2
}

Edited by Warzouz
Link to comment
Share on other sites

  • 3 weeks later...
On 2016-01-15 at 4:40 AM, Warzouz said:

Full throttle on the launchpad

  Hide contents

@PHYSICSGLOBALS
{
   prelaunchDefaultThrottle = 1
}

 

With KSP 1.1.0 and ModuleManger for it, I've found you need to edit this (I set my initial throttle to 0).

Quote

@PHYSICSGLOBALS
{
    @prelaunchDefaultThrottle = 1
}

 

Link to comment
Share on other sites

1 hour ago, nli2work said:

where is "PHYSICSGLOBALS"? is that something from ModuleManager? or in KSP? I don't see it in settings.cfg 

is it possible to manipulate values in settings.cfg with MM?

It's how  MM accesses Physics.cfg, an important repository of parameters for many KSP physics concepts like aero, thermal, buoyancy, and even prelaunchDefaultThrottle.  MM scripts like my MMJ-Jacke-Default_Throttle-1.0.cfg (below with comments removed) can change these parameters' values after they are loaded into KSP, similar to the way it can change other parameters, as always without changing the original files.

@PHYSICSGLOBALS
{
    @prelaunchDefaultThrottle = 0	// default 0.5 ie. 50%, since KSP 0.24
}

(Physics.cfg is an important file *not* to change as there were bugs in KSP 1.0+ that corrupted the values in Physics.cfg.  Deleting the file was supposed to have KSP regenerate it with default values, but that regenerated file had even more values corrupted.  To fix it the file had to be restored from the program source, either Steam or the KSP store download.)

Link to comment
Share on other sites

i guess this is where i should ask for help. im trying to make the smaller antennas in remotetech physicsless, like the stock antennas. (it adds the mass ot the parent part now, o IMO, it fari, just makes COG balancing a it easier) what i have here does not work. what am i doing wrong?

//Communotron 32
@PART[RTLongAntenna2]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
//CommTech EXP-VR-2T
@PART[RTLongAntenna3]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
//Reflectron LL-5
@PART[RTLongDish1]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
//Reflectron DP-10
@PART[RTShortAntenna1]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
/Reflectron KR-7
@PART[RTShortDish2]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}

i did try physics significance=0, did not work. according to the wiki, physicssignificance=1 sets the part to physicsless.

Link to comment
Share on other sites

39 minutes ago, toric5 said:

i guess this is where i should ask for help. im trying to make the smaller antennas in remotetech physicsless, like the stock antennas. (it adds the mass ot the parent part now, o IMO, it fari, just makes COG balancing a it easier) what i have here does not work. what am i doing wrong?

Spoiler


//Communotron 32
@PART[RTLongAntenna2]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
//CommTech EXP-VR-2T
@PART[RTLongAntenna3]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
//Reflectron LL-5
@PART[RTLongDish1]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
//Reflectron DP-10
@PART[RTShortAntenna1]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}
/Reflectron KR-7
@PART[RTShortDish2]:AFTER[RemoteTech]:FOR[RemoteTech]
{
@PhysicsSignificance=1
}

i did try physics significance=0, did not work. according to the wiki, physicssignificance=1 sets the part to physicsless.

I believe you should replace ":FOR[RemoteTech]" with "NEED[RemoteTech]", as :FOR is more for the mod's own .cfg files, while metamods for the mod should use :NEED.

As well, most parts don't explicitly have PhysicsSignificance parameters, so you should use the edit-or-create operator version "%PhysicsSignificance = 1".

Edited by Jacke
Link to comment
Share on other sites

16 minutes ago, Jacke said:

I believe you should replace ":FOR[RemoteTech]" with "NEED[RemoteTech]", as :FOR is more for the mod's own .cfg files, while metamods for the mod should use :NEED.

As well, most parts don't explicitly have PhysicsSignificance parameters, so you should use the edit-or-create operator version "%PhysicsSignificance = 1".

thank you. got it working now.

Link to comment
Share on other sites

how do I wildcard Modules only within a Mod folder? would this config have to be placed inside the ModFolder?

@PART[*]:HAS[@Module[IWantToChange]]:FOR[ModFolder]{ }?

Edited by nli2work
Link to comment
Share on other sites

  • 2 weeks later...
On 5/2/2016 at 1:27 AM, nli2work said:

how do I wildcard Modules only within a Mod folder? would this config have to be placed inside the ModFolder?

@PART[*]:HAS[@Module[IWantToChange]]:FOR[ModFolder]{ }?

If you are only looking to apply it to a certain author's mods, maybe try filtering via the author's name.

@PART[*]:HAS[#author[NAME], @MODULE[TargetModule]]

I might be wrong here, but Im pretty sure this works.

 

 

Link to comment
Share on other sites

Does anyone know how to multiply an existing (unspecified) value? I wanna increase all engine ISPs by 30%, but I can't seem to find any way of referencing a value that already exists. I can see ways to edit or create a new specific number, but that would only work if I wanted all engines to have the same ISP, or if I went to create an individual patch for every engine. Here is what I have (I'm sorry if I've committed any coding sin; it's literally like the first piece of code I've ever written):

@PART[*]:HAS[@MODULE[ModuleEngineFX]]:Final
{
	@atmosphereCurve
	{
		@key,0 = (*)*1.3
		@key,1 = (*)*1.3
	}
}

 

Link to comment
Share on other sites

1 hour ago, MrMeeb said:

Does anyone know how to multiply an existing (unspecified) value? I wanna increase all engine ISPs by 30%, but I can't seem to find any way of referencing a value that already exists. I can see ways to edit or create a new specific number, but that would only work if I wanted all engines to have the same ISP, or if I went to create an individual patch for every engine. Here is what I have (I'm sorry if I've committed any coding sin; it's literally like the first piece of code I've ever written):


@PART[*]:HAS[@MODULE[ModuleEngineFX]]:Final
{
	@atmosphereCurve
	{
		@key,0 = (*)*1.3
		@key,1 = (*)*1.3
	}
}

 

Hello, you can see the examples on the official threads, and it's var *= factor

Quote

@PART[*]:FOR[Realism] {
    @mass *= 0.25
    @maxTemp -= 500
    @scale += 2
  }
Edited by Malah
Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

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