Difference between revisions of "CFG File Format"
From Kerbal Space Program Wiki
m (Reverted edits by Rocketing Rudolph (talk) to last revision by Lexxy Fox) |
Electrollama (talk | contribs) (Redirected page to CFG File Documentation) |
||
(One intermediate revision by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | #REDIRECT [[CFG File Documentation]] | ||
+ | |||
KSP uses a custom file format for various purposes such as part definitions, save files, and config files. | KSP uses a custom file format for various purposes such as part definitions, save files, and config files. | ||
Line 43: | Line 45: | ||
* [[User:Greys#Conventions]] | * [[User:Greys#Conventions]] | ||
* [[User:Greys#Config_Nodes|A better explanation of the config node format]] | * [[User:Greys#Config_Nodes|A better explanation of the config node format]] | ||
+ | |||
+ | [[Category:Modding]] |
Latest revision as of 10:13, 24 May 2021
Redirect to:
KSP uses a custom file format for various purposes such as part definitions, save files, and config files.
Low-level Format
Config file nodes contain a list of key = value pairs, and other nested config nodes. Keys and values are both strings and nested config nodes also have a key. Duplicate keys ARE allowed. CFG Files also support comments. In the data model, nested config nodes are generally separate from key-value pairs, and the node key typically defines the node's type. Keys are case sensitive. The order of node content doesn't matter.
- Key-value pairs
- Keys and values are separated by an equals sign ("="). Values are read until the end of the line, EOF, or the start of a comment.
- Nodes
- Config nodes start with their name, followed by an opening curly brace ("{") on its own line, their contents, and end with a closing curly brace ("}") on another separate line. The general convention is that config node keys are in all capital letters. Generally, node contents are indented by a single tab character.
- Comments
- Comments start with a double forward slash ("//") and continue until the end of the line or EOF.
Basic Value Types
Although values are just strings, the config file codec in KSP contains a few utility methods for serializing common data types which map directly to Unity Engine classes.
Type tree:
- Array-likes
- Arrays elements are separated by either commas, spaces, or tabs (by default the config writer uses a comma followed by a space). For basic array types, listed below are the Unity Engine class the type maps to in bold, the primitive type of the array elements, and it's length. Other arrays can have any arbitrary length.
- Color types
- UnityEngine.Color <Float> [3 or 4]
- UnityEngine.Color32 <Byte> [3 or 4]
- Quaternion types
- UnityEngine.Quaternion <Float> [4]
- UnityEngine.QuaternionD <Double> [4]
- UnityEngine.Matrix4x4 <Float> [16]
- Vector types
- UnityEngine.Vector2 <Float> [2]
- UnityEngine.Vector3 <Float> [3]
- UnityEngine.Vector3D <Double> [3]
- UnityEngine.Vector4 <Float> [4]
- Enums
- The config writer serializes enumerations automatically.