Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
mdf_file_format [2021/06/04 08:54] – [Properties] nlondon | mdf_file_format [2023/09/01 16:05] (current) – Added more information to Array nlondon | ||
---|---|---|---|
Line 2: | Line 2: | ||
- | MDF stands for Mars Data Format. It's a JSON-esque file format that's used to define almost all user-accessible data for the [[Mars Engine]]. | + | MDF stands for Mars Data Format. It's a JSON-esque file format that's used to define almost all user-accessible data for the [[Mars Engine]]. They are used for '' |
====== Properties ====== | ====== Properties ====== | ||
- | A property is any string of characters, called the **Name**, followed by an '' | + | A property is any string of characters, called the **Name**, followed by an '' |
- | **Name** and **Value** must be made out of [[#Valid Identifier Characters]], or be surrounded by double quote marks. | + | **Name** must be made out of [[#Valid Identifier Characters]]. |
< | < | ||
- | Name = Value | ||
Name = " | Name = " | ||
</ | </ | ||
Line 18: | Line 17: | ||
====== Valid Identifier Characters ====== | ====== Valid Identifier Characters ====== | ||
- | Names and Values | + | Property |
< | < | ||
A-Z a-z 0-9 _!+-. | A-Z a-z 0-9 _!+-. | ||
</ | </ | ||
- | Optionally, you can also surround the Name or Value with double quotes to include otherwise illegal characters, such as spaces, colons, and so on. | + | Optionally, you can also surround the Name with double quotes to include otherwise illegal characters, such as spaces, colons, and so on. |
< | < | ||
✅ ThisIsAValidIdentifier | ✅ ThisIsAValidIdentifier | ||
Line 38: | Line 37: | ||
====== Elements ====== | ====== Elements ====== | ||
- | An MDF is made up of sections collectively referred to as **Elements**. There are three major types of element; [[# | + | The value of a property is defined using an **Element**. There are three major types of element; [[# |
===== Value ===== | ===== Value ===== | ||
- | + | A **Value** element is just a string of characters that will be assigned to the property. They must start and end with double quotes (''"'' | |
- | A *Value* element is just a string of characters that will be assigned to the property. | + | |
< | < | ||
MyValue = "This is MyValue!" | MyValue = "This is MyValue!" | ||
+ | IllegalValue = This isn't a valid value, as it's missing the double quotes | ||
</ | </ | ||
===== Chunk ===== | ===== Chunk ===== | ||
- | TODO | + | A **Chunk** element is a collection of named [[# |
+ | |||
+ | Note that a property name can only be used once per chunk, if there are multiple properties with the same name, only the last property will be used. | ||
+ | |||
+ | < | ||
+ | MyChunk = | ||
+ | { | ||
+ | SomeValue = "This is a value in the chunk" | ||
+ | DuplicateValue = "This value will be overwritten" | ||
+ | DuplicateValue = "This value overwrote the value above" | ||
+ | |||
+ | SubChunk = | ||
+ | { | ||
+ | Value = "This chunk is a child of MyChunk" | ||
+ | } | ||
+ | |||
+ | ArrayProperty = | ||
+ | [ | ||
+ | " | ||
+ | ] | ||
+ | } | ||
+ | </ | ||
===== Array ===== | ===== Array ===== | ||
- | TODO | + | **Array** elements are very similar to [[#Chunk]] elements, in that they contain multiple other properties, but the specific difference is that properties in an array don't need to define a name. They //can// define a name, if required, and duplicate names are also allowed. Arrays are defined by using a starting square bracket ('' |
+ | |||
+ | Like [[# | ||
+ | |||
+ | < | ||
+ | MyArray = | ||
+ | [ | ||
+ | " | ||
+ | NamedElement = "This is an element with a name" | ||
+ | NamedElement = "This element uses the same name, but does not overwrite the previous element" | ||
+ | |||
+ | { | ||
+ | Value = "This is an unnamed chunk in an array" | ||
+ | } | ||
+ | |||
+ | [ | ||
+ | " | ||
+ | ] | ||
+ | ] | ||
+ | </ | ||