User Tools

Site Tools


en:orx:config:syntax

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
en:orx:config:syntax [2010/05/11 20:45 (14 years ago)] – RGB!! iarwainen:orx:config:syntax [2023/05/15 20:19 (11 months ago)] (current) sausage
Line 92: Line 92:
 In the section 'Child', there's only one key defined called 'MyKey'. Its value is inherited from the 'Parent' section who already inherits it from the 'GrandParent' one. In other words, when ''GrandParent.MyKey'' changes, both ''Parent.MyKey'' and ''Child.MyKey'' will be affected. In the section 'Child', there's only one key defined called 'MyKey'. Its value is inherited from the 'Parent' section who already inherits it from the 'GrandParent' one. In other words, when ''GrandParent.MyKey'' changes, both ''Parent.MyKey'' and ''Child.MyKey'' will be affected.
  
 +All values can implicitly refer to their own section using the inheritance marker '@' by itself. Its value will be dynamic and carry and inheritance to always result in the name of the child section.
  
 +A parent can be removed when overriding a section and using no name after '@'. The implicit default parent section can be ignored using the specific '@@' syntax.
 +
 +<code ini>[Object] <= This section doesn't use any explicit parent but will use the implicit default parent if defined
 +[Object@Template] <= This section now uses 'Template' as an explicit parent section;
 +[Object@] <= This section now has removed any explicit parent but is still using the implicit default parent if defined
 +[Object@@] <= This section now has removed any parent and will not use the implicit default parent section either</code>
 +
 +To learn more about the default parent section, please refer to [[en/orx/config/settings_main/main#config_module|the Config section of the main settings page]].
 +
 +<code ini>[Template]
 +MyKey = @; <= The value for 'MyKey' will be 'Template', the name of this section
 +MyOtherKey = @; <= Same here, the value for 'MyOtherKey' will also be the name of this section: 'Template'
 +
 +[Object@Template]
 +MyNewKey = @; <= The value for 'MyNewKey' will be 'Object'
 +MyKey = @Template; <= The value for 'MyKey' will be inherited from the section 'Template' using the same key and its value will be 'Object', ie. this section, not the parent one, 'Template'</code>
 +
 +MyOtherKey will also use the section inheritance and its value will be 'Object', ie. this section, not the parent one, 'Template'.
 ===== Includes ===== ===== Includes =====
  
Line 113: Line 132:
  
 Key2 = Var2; <= this will still be added to the 'MySection' section</code> Key2 = Var2; <= this will still be added to the 'MySection' section</code>
 +
 +===== Command =====
 +The Command module allows you to execute Orx functions from both the console and .ini files. Syntax for .ini files is specified in https://github.com/orx/orx/blob/master/code/bin/SettingsTemplate.ini. Console usage is discussed here: [[en:tutorials:command:commandnotes|Command Module notes]].
  
  
Line 118: Line 140:
  
 ==== Basic types ==== ==== Basic types ====
 +
 +Boolean values are expressed with literals ''true'' and ''false'':
 +
 +<code ini>VSync = true</code>
  
 Floating points (float) values are expressed using a decimal separator ('.'). Floating points (float) values are expressed using a decimal separator ('.').
Line 142: Line 168:
 ==== Vector ==== ==== Vector ====
  
-Vectors are always defined using three components, separated by commas (',') and enclosed by either round brackets ('()') or curly brackets ('{}'), with no distinction.+Vectors are always defined using **three** components, separated by commas (',') and enclosed by either round brackets ('()') or curly brackets ('{}'), with no distinction.
  
 <code ini>MyVector      = (1.0, 2.0, 3.0) <code ini>MyVector      = (1.0, 2.0, 3.0)
Line 151: Line 177:
 ==== Random ==== ==== Random ====
  
-Whenever numerical values are used ((Ints, Floats and Vectors)), a random generated value can be obtained using the tilde character ('~') to separate the low and the high boundaries.+Whenever numerical values are used ((Ints, Floats and Vectors)), a random generated ((In order to guarantee the generated value will be different on each run, call orxMath_InitRandom at the start of the program. Seed it with a perpetually changing integer, e.g. milliseconds since the Unix epoch.)) value can be obtained using the tilde character ('~') to separate the low and the high boundaries.
  
 <code ini>RandomInt    = 1 ~ 10 <code ini>RandomInt    = 1 ~ 10
Line 158: Line 184:
  
 Every time the value for a random defined key is queried in the code, a new random value between the specified boundaries will be generated. Every time the value for a random defined key is queried in the code, a new random value between the specified boundaries will be generated.
- 
- 
 ===== Lists ===== ===== Lists =====
  
 Lists of values for a single key are also supported. All the elements are separated using the pound character ('#'). Lists can also contains random values as elements. Lists of values for a single key are also supported. All the elements are separated using the pound character ('#'). Lists can also contains random values as elements.
  
-<code ini>ListValue = Val1#Val2#RandVal3 ~ RandVal4#Val5</code>+<code ini>ValueList = Val1 # Val2 # RandVal3 ~ RandVal4 # Val5</code>
  
-If spaces are defined around the list separators '#' they will be ignored.+If spaces are defined around the list separators '#'they will be ignored.
  
 +**NB: Spaces around the list delimiter ('#') are trimmed and will simply be ignored by the config system.**\\
 **NB: When querying lists using the config API, please look at the functions containing the word 'List' in their name. If you use a non-list function to query a key that contains a list value, any element of the list will be randomly returned.** **NB: When querying lists using the config API, please look at the functions containing the word 'List' in their name. If you use a non-list function to query a key that contains a list value, any element of the list will be randomly returned.**
  
-But let's visualize this with an example. =)\\+But let's visualize this with examples. =)\\
 Code Code
  
-<code c>orxFLOAT fMyFloat = orxConfig_GetFloat("MyFloat");</code>+<code c>orxVECTOR vMyVector; 
 +orxConfig_GetVector("MyVector", &vMyVector); 
 +orxFLOAT fMyFloat = orxConfig_GetFloat("MyFloat");</code>
  
 INI INI
  
-<code ini>MyFloat = 1.0 # 2.0 # 3.0</code>+<code ini>MyVector = (1, 2, 3) # (4.0, 5.0, 6.0) 
 +MyFloat = 1.0 # 2.0 # 3.0</code>
  
-The function will then randomly return 1.0, 2.0 or 3.0.((The spaces are not important here as we're using numerical values))\\ +The functions will then randomly return (1, 2, 3) or (4.0, 5.0, 6.0) for the vector one, and 1.0, 2.0 or 3.0 for the float one.\\ 
-If the value was defined with using a random separator ('~'), any float value between 1.0 and 3.0 could have been returned.\\+If the values were defined using a random separator ('~'), any vector between (1, 2, 3) and (4.0, 5.0, 6.0) or any float value between 1.0 and 3.0 could have been returned.\\
 Please also note that controlled randoms using lists works also with non-numerical values. Please also note that controlled randoms using lists works also with non-numerical values.
 +
 +Lists can span multiple lines when using # at the end of the line (line ending comments are allowed).\\
 +If you want to define an empty element at the end of a list, use ##\\
 +
 +Example:
 +<code ini>Key2 = Var1 # Var2 #
 +       Var3 #; This list still continues on next line and this comment is valid.
 +       Var4  ; This list is now complete and contains 4 elements.
 +Key3 = Var1 # Var2 ##; This list will not span on the next line but will contain a 3rd (and last) empty element.</code>
en/orx/config/syntax.1273635950.txt.gz · Last modified: 2017/05/30 00:50 (7 years ago) (external edit)