Support | News | Classic | F.A.Q. | Discord | Discussions | Wiki | Roadmap

Master Modding

Build menus

Editor group menus
Editor group menus are the icons you see in build mode which represent the groups into which parts are categorized. For example weapons would go into the weapons group. For a part to be sorted into an editor group the part.txt has to have this line: EditorGroup = "Weapons"

Cosmoteer 0.9.13 to present
In order to create a new custom editor group it has to be added to vanilla's editor_groups.txt via the mod.txt

	{
		Action = Add
		AddTo = "<Gui/editor groups.txt>"
		Name = "Special"
		ToAdd
		{
			NameKey = "EditorGroups/Special"
			Icon
			{
				Texture = "Gui/group_special.png"
			}
		}
	}

or more advanced

	{
		Action = Overrides
		OverrideIn = "<gui/game/designer/editor_groups.txt>"
		Overrides = &<gui/editor_groups.txt>
	}

Then it has to be added to the en.txt.

EditorGroups
{
	Special = "Special"
}

A part in this new group has to be set as follows:

	EditorGroup = "Special"
	EditorGroupKey = "EditorGroups/Special"

Ship classes

A ship class is for example Terran or Asteroid. Ship classes can have their own specific parts that cannot be build by other ship classes. They can also offer the same parts as other classes.

To create a custom ship class it has to be added to vanilla's rules.txt via the mod.txt.

	{
		Action = AddMany
		AddTo = "<rules.txt>/Ships"
		ManyToAdd
		[
			&<Abh.txt>/Abh
		]
	}

Next the ship class has to be setup with its parts, its doors, special writing rules, its RenderLayers, Blueprint and decal roof.

Abh : <../../Data/Ships/base ship.txt>
{
	IDString = Abh
	OtherIDs = ["MyShips"]
	NameKey = "ShipClasses/Abh"
	DefaultPartID = corridor
	DefaultDoorID = door
	HoleDoorID = wall_hole
	ExternalWalls = &<../../Data/Ships/Terran/Walls/external walls.txt>
	ExternalRoofWalls = &<../../Data/Ships/Terran/Walls/external roof walls.txt>
	CommandRequiredCategories = ["command"]

Parts
[
	// Basic.
	&<../../Data/Ships/Terran/corridor/corridor.txt>/Part
]

Doors
[
	&<../../Data/Ships/Terran/door/door.txt>
	&<../../Data/Ships/Terran/wall_hole/wall_hole.txt>
]

CategoryNouns
[
	{Category=thruster; SingularKey="CategoryNouns/ThrusterSingular"; PluralKey="CategoryNouns/ThrusterPlural"}
]

RenderLayers
[
	// Floors.
	{
		Key = "floors"// Ship bucket layer.
		Value // The actual material.
		{
			UniqueBucket = -400
			RenderStage = Lower
			DrawWithShipGhost = true
			AtlasTextureParams
			{
				SampleMode = Point
				MipLevels = 7// Assumes 64x64 min part sprite size.
			}
			Material
			{
				Shader = "../../Data/Ships/Common/parts.shader"
			}
		}
	}
]

Blueprints : <../../Data/Ships/base ship.txt>/Blueprints
{
	ExternalWalls = &<../../Data/Ships/Terran/Walls/external blueprint walls.txt>
}

Roofs : <../../Data/Ships/base ship.txt>/Roofs
{
	RoofTexturesFolders = ["../../Data/Ships/Terran/Roof Textures"]
	DefaultRoofTexture = "plates1"
	RoofDecalsFolders = ["Roof Decals"]
}
}

Special case
For parts being shared between ship classes and being sorted to different editor groups these parts have to be re-assigned via a representative. See Inheritance section.

Part : <photon_torpedo_tube.txt>/Part
{
    ID = "Lafiel.photon_torpedo_tube",OtherIDs = ["photon_torpedo_tube"]
	EditorGroup = "WeaponsMissile"
}

To limit the number of certain parts these parts should have a unique category. This will prevent the limitation to be applied accidentally to other parts.

	CategoryLimits
	[
		{Category = "lab"; Max = 4}
	]

Inheritance

Inheritance is an advanced technique which enables reusing code. However, it does not always work and has to be treated case by case. Currently, inheritance (0.14.x) does not work with shields with regards to size or orientation.
The basic invocation for inheritance is marked by : followed by the parent from which it inherits. Note: line placement is important as it can be misinterpreted especially when followed by a group. If the group is not related to the inheritance itself separate it by one empty line.

Part : <photon_torpedo_tube.txt>/Part
	Components : ^/0/Components, <../t/bio_regen.txt>, <../t/bio_shield.txt>
		Graphics : &<../t/g1x1.txt>/Graphics

Settings or values can be overridden by re-declaring them. This does not always work for example with sprites or animation and has to be treated case by case.

				: /BASE_SOUNDS/AudioInterior
				{
					Sound = "operating.wav"
					Volume = .15
					MaxConcurrentVolume = .3
					Speed = .75
					MaxConcurrent = 1
				}

Custom sound effect extraordinaire

Usually, custom sound effects for parts can just be added by using simple inheritance and adjusting the path to a sound file:

				: /BASE_SOUNDS/AudioExterior
				{
					Sound = "shoot.wav"
					Volume = .75
					SpeedVariation = .25
				}

However, it's not that simple if you want to create a custom sound effect which can be called like particle effects.
Sound effects have to inherit from a sound class for convenience and consistency.
Sound classes are defined in base_sounds.txt.

AudioExterior
{
	Type = Audio

	DynamicVolume
	{
		MinDistance = 0
		MaxDistance = 12
		DistanceFalloff = 1

		MinZoom = 1
		MaxZoom = 70
		ZoomFalloff = 2
	}

	DynamicFilter
	{
		MinDistance = 0
		MaxDistance = 2
		DistanceFalloff = 1

		MinZoom = 1
		MaxZoom = 12
		ZoomFalloff = 2

		Filter
		{
			FilterType = LowPassAmplify
			FromFrequency = 7350
			ToFrequency = 500
			FrequencyFactorExponent = 0.5
		}
	}

	MaxConcurrent = 5
}

Alternatively, stand alone sounds effects can be defined in common_sounds.txt. These are the same as sound classes but use more options.

ThrusterBurst
{
	Type = Audio

	DynamicVolume
	{
		MinDistance = 0
		MaxDistance = 1.5
		DistanceFalloff = 1

		MinZoom = 1
		MaxZoom = 12
		ZoomFalloff = 5
	}

	Sound = "thruster_burst.wav"

	MaxConcurrent = 2
	ConcurrencyDuration = 1

	RampUpTime = .1
	RampDownTime = .1
}

Sound effects are defined in common_effects.txt.

AlertNavalKlaxon
[
	: /BASE_SOUNDS/AudioExterior //AudioInterior
	{
		Sound = "../sounds/alert_klaxon.wav"
		Volume = 1
		SpeedVariation = .1
		MaxConcurrentVolume = 1.2
		MaxConcurrent = 1
	}
]

With this you can call it as &/COMMON_EFFECTS/AlertNavalKlaxon
Use proper add action in mod.txt to add these files.

	{
		Action = Overrides
		OverrideIn = "<./Data/common_effects/common_effects.txt>"
		Overrides = &<Effects/common_effects.txt>
	}

To be continued

7 months later

Lafiel adding something to categorylimits of terran should also be possible, right?

    {
    	Action = Add
    	OnlyIfNotExisting = true
    	AddTo = "<ships/terran/terran.txt>/Terran"
    	Name = CategoryLimits
    
    	ToAdd = [{Category = "singularity_core"; Max = 4}, {Category = "time_warp_core"; Max = 6}]
    }

      Lafiel but what if 2 mods do that? Wouldn't that cause issues?

        Catelyn Different topic!
        Currently, it's only possible to check whether it's already there or not. I've addressed mod.txt and Base_Part collisions with Walt last year. It doesn't seem to be solve-able anytime soon especially buffs, factors and multipliers. So the general rule is to be cautious and minimalistic when modifying vanilla base_part, base_ships etc.

          5 months later

          I can't get my own render layer to work. Can you help me with this?

          {
          	Action = Add;
          	AddTo = "<Ships/Terran/terran.txt>/Terran/RenderLayers"
          	ToAdd
          	{
          		Key = "low_roof"// Ship bucket layer.
          		Value // The actual material.
          		{
          			UniqueBucket = -500
          			RenderStage = Upper
          			DrawWithShipGhost = false
          			IsRoof = true
          			Inflate = .0001
          			AtlasTextureParams
          			{
          				SampleMode = Point
          				MipLevels = 7// Assumes 64x64 min part sprite size.
          			}
          			Material
          			{
          				Shader = "roof colored.shader"
          				Shader = "../../Data/Ships/Common/roof_colored.shader"
          			}
          		}
          	}
          }

            lugerun replace ../../Data with ./Data

              still crashes ...

              Halfling.Serialization.DeserializeException: Deserialization from source "<D:\Program Files (x86)\Games\Cosmoteer\Data\rules.txt>" failed. ---> System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> Halfling.Serialization.DeserializeException: Deserialization from source "<D:\Program Files (x86)\Games\Cosmoteer\Data\Ships\Terran\terran.txt>/Terran" failed. ---> System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. ---> Halfling.Serialization.DeserializeException: Deserialization from source "<[user's home folder]\Documents\My Games\Cosmoteer\Mods\add_fair\mod.txt>/Actions/0/ToAdd/Value/Material/Shader" failed. ---> System.IO.IOException: Unable to open file [user's home folder]\Documents\My Games\Cosmoteer\Mods\add_fair.Data\Ships\Common\roof_colored.shader

              bei SharpDX.IO.NativeFileStream..ctor(String fileName, NativeFileMode fileMode, NativeFileAccess access, NativeFileShare share)

              But thanks for the reply.

                lugerun This is a guide thread it should have posts regarding the guide or specific modding topics and their discussion. To keep things tidy and neat to help modders without having to read through random post.
                Please create your own thread in "Mod Development" for specific modding help/questions/problems etc.

                For your problem use "AddMany" that's all.

                  Lafiel he has 2 shader references tho?

                  Catelyn You are correct. 👍

                    7 days later

                    I just copied the original shader to test if the path to the shader is the problem. Commented one out at any time thou.

                    At time of writing i wasn't able to create a discussion. But seems it like this problem vanished.

                      Write a Reply...