Difference between revisions of "CFG File Format"

From Kerbal Space Program Wiki
Jump to: navigation, search
(Created page with "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 = v...")
 
Line 3: Line 3:
 
== Low-level Format ==
 
== 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.
+
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.
  
 
* '''Key-value pairs'''
 
* '''Key-value pairs'''
Line 11: Line 11:
 
* '''Nodes'''
 
* '''Nodes'''
  
Config nodes start with their key name, followed by an opening curly brace ("{"), their contents, and end with a closing curly brace ("}").
+
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'''
  
 
Comments start with a double forward slash ("//") and continue until the end of the line or EOF.
 
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.

Revision as of 15:13, 14 March 2016

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.

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