This shows you the differences between two versions of the page.
xg:function_script [2017-03-22 07:16] – skyjake | xg:function_script [2017-03-22 07:17] (current) – skyjake | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Function script (XG) ====== | ||
+ | |||
+ | //XG functions// are functions in a mathematical sense. They evaluate to a number that might change as time goes by. XG functions are strings. Some characters are interpreted as control characters and others represent values from zero to one. [[modding: | ||
+ | |||
+ | |||
+ | ===== Symbols ===== | ||
+ | |||
+ | |||
+ | The table below lists all the symbols that can be used in functions. There can be any number of spaces between two symbols. Often adding a couple of spaces makes the function easier for humans to understand. | ||
+ | |||
+ | ^ Symbol^ Meaning | | ||
+ | | a ... z| Values from zero to one. Values between two consecutive lowercase letters will be interpolated. Example: '' | ||
+ | | A ... Z| Values from zero to one. Won't be interpolated between steps. | | ||
+ | | /| Exact value. A floating point number must immediately follow. Corresponds a lowercase letter, so interpolation will be done. Example: '' | ||
+ | | %| Exact value. A floating point number must immediately follow. Corresponds an uppercase letter, so there will be no interpolation. Example: '' | ||
+ | | (number)| Repeat the following value this many times. The value must follow the number immediately. Example: '' | ||
+ | | .| Break interpolation. Placing a period after a lowercase letter will cause the evaluator to skip the letter. Example: '' | ||
+ | | #| Set step timer. A number must immediately follow a # symbol. Example: '' | ||
+ | | ?| Random step timer. A number must immediately follow a ''?'' | ||
+ | | >| Begin of repeat sequence marker. The evaluator skips this. | | ||
+ | | <| Repeat. Makes the evaluator jump to the beginning of the function or to the latest > marker. Example: '' | ||
+ | | !| Chain event. A line type ID must immediately follow the exclamation point ! . The event will be an activating one and it will be sent in the beginning of the step (when the evaluator arrives at the value following the ! symbol). Example: '' | ||
+ | |||
+ | |||
+ | The first character of a function string can also be a special character: | ||
+ | |||
+ | ^ Symbol^ Meaning | | ||
+ | | =| Linked function. The value of the function is linked to the value of another function of the same sector (their values are always equal). The character following the equal sign = determines which function this one will be linked to: \\ - '' | ||
+ | | +| Dynamic offset. When the function is initialized (at the beginning of the level or when the sector type is set) its offset will be modified depending on the character following the plus sign '' | ||
+ | |||
+ | |||
+ | ===== Evaluation of functions ===== | ||
+ | |||
+ | |||
+ | The first actual symbol of a (non-linked) function string must be a value (an uppercase or a lowercase letter or an exact value). It is the initial value of the function. | ||
+ | |||
+ | Each value symbol defines a step. The evaluator advances to the next step when the timer for the current one reaches zero. The type definition specifies the minimum and maximum number of tics for each step. If the step timer isn't set with the # or ? symbols, it will be set to a random number between the minimum and maximum tics for each step. Interpolation is always done between the current step and the next one. If both are interpolateable (lowercase letter or an exact value defined with a slash / ) the value of the function will gradually blend from the current step's value to the next one's. | ||
+ | |||
+ | The current value of a step will be multiplied with a scaling factor and an offset will be added. Acceptable values for the function depend on the context: for example, light and color functions are automatically scaled with 255 and have no offset. The floor and ceiling functions' | ||
+ | |||
+ | Examples: | ||
+ | |||
+ | ^ Function^ Meaning | | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | | '' | ||
+ | |||
+ | |||
+ | |||
+ | ===== See also ===== | ||
+ | |||
+ | * [[colored_xg_sector_lighting_example]] | ||
+ | |||
+ | |||