Changes for page Mission Director Guide

Last modified by Klaus Meyer on 2025/03/31 16:39

From version 32984.1
edited by Klaus Meyer
on 2025/03/31 16:39
Change comment: There is no comment for this version
To version 32958.1
edited by Daniel Turner
on 2023/08/22 19:09
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.Klaus
1 +xwiki:XWiki.Daniel
Content
... ... @@ -22,7 +22,7 @@
22 22  This functionality is only available if the schema files **md.xsd** and **common.xsd** are in the correct folder. If you are editing the XML in the game folder directly, all is well and the files are loaded from the libraries folder. However, if you are editing in a separate folder, copy those XSD files from the libraries folder directly into the folder where your XML files are located.
23 23  
24 24  {{info}}
25 -Even if your script is free of XSD errors, that does not mean that the script syntax is correct. For example, there are XML elements that require at least one of multiple attributes, but this requirement cannot be reflected in a schema (apart from documentation text). Please notice the XSD documentation of the elements and attributes, e.g. displayed via tooltips in Visual Studio / Visual Web Developer. Please also note additional requirements for MD cue attributes in this guide (see [[Conditions>>doc:||anchor="HConditions" style="outline-width: 0px !important; user-select: auto !important;"]]).
25 +Even if your script is free of XSD errors, that does not mean that the script syntax is correct. For example, there are XML elements that require at least one of multiple attributes, but this requirement cannot be reflected in a schema (apart from documentation text). Please notice the XSD documentation of the elements and attributes, e.g. displayed via tooltips in Visual Studio / Visual Web Developer. Please also note additional requirements for MD cue attributes in this guide (see [[NULL|Conditions]]).
26 26  
27 27  To check for errors, please pay attention to in-game error messages that are produced while your script is imported, and run-time errors while the script runs. The XSD files can help you a lot, but you should not rely on the absence of XSD errors."
28 28  {{/info}}
... ... @@ -157,7 +157,7 @@
157 157  
158 158  * With //checkinterval//, you can specify a constant time interval between condition checks. The conditions will be checked regularly forever until they are met, unless the cue's state is changed explicitly by an external event.
159 159  
160 -Additionally, you can use the attribute **checktime** to set the time of the first condition check (also possible in combination with //onfail//). The //checktime// can be an expression with variables and is evaluated when the cue is enabled (when the condition checks would normally start - for root cues that happens at game start, otherwise after the parent cue becomes active).
160 +Additionally, you can use the attribute **checktime** to set the time of the first condition check (also possible in combination with //onfail//). The //checktime// can be an expression with variables and is evaluated when the cue is enabled (when the condition checks would normally start ΓÇô for root cues that happens at game start, otherwise after the parent cue becomes active).
161 161  
162 162  Examples:
163 163  
... ... @@ -217,9 +217,11 @@
217 217  {{/code}}
218 218  
219 219  {{info}}
220 -Messages printed with <debug_text> are usually only visible when the "scripts" debug filter is enabled, see [[Script debug output>>doc:||anchor="HScriptdebugoutput"]]
220 +Messages printed with <debug_text> are usually only visible when the "scripts" debug filter is enabled, see Script debug output
221 221  {{/info}}
222 222  
223 +
224 +
223 223  Each child action in a <do_any> node can have a //**weight**// attribute, which can be used to control the random selection of an action node. The default weight of a child node is 1.
224 224  
225 225  Also available is **<do_if>**, which completes the enclosed action(s) only if one provided value is non-null or matches another. Directly after a <do_if> node, you can add one or more **<do_elseif>** nodes to perform additional checks only in case the previous conditions were not met. The node **<do_else>** can be used directly after a <do_if> or a <do_elseif>. It is executed only if none of the conditions are met.
... ... @@ -226,11 +226,8 @@
226 226  
227 227  **<do_while>** also exists, but should be used carefully, since it is the only action that could cause an infinite loop, which freezes the game without any chance of recovery.
228 228  
229 -Every action can have a //**chance**// attribute, if you only want it to be performed with that chance, given as percentage. Otherwise it will simply be skipped.
231 +Every action can have a //**chance**// attribute, if you only want it to be performed with that chance, given as percentage. Otherwise it will simply be skipped. If chance is used on a conditional action such as <do_if>, the script will behave as if the condition check failed.
230 230  
231 -* If chance is used on a conditional action such as <do_if>, the script will behave as if the condition check failed.
232 -* If chance is provided on an action within a <do_any>, it will have no effect on the random selection of the action. Only when the action gets selected, the chance will determine whether the action actually gets performed or skipped.
233 -
234 234  = Libraries =
235 235  
236 236  Libraries are cues which are not created directly but only serve as templates for other cues. This allows for modularisation, so you can re-use library cues in many different missions.
... ... @@ -240,6 +240,7 @@
240 240  {{/info}}
241 241  
242 242  
242 +
243 243  Library cues are written like normal cues, they are also defined in a <cues> node, just with the difference that the XML tag is called library instead of cue:
244 244  
245 245  {{code language="xml"}}
... ... @@ -290,9 +290,11 @@
290 290  {{/code}}
291 291  
292 292  {{warning}}
293 -These examples are definitely **__not__ **examples of good scripting style.
293 +These examples are definitely <u>not</u> examples of good scripting style.
294 294  {{/warning}}
295 295  
296 +
297 +
296 296  So when writing the library, you don't have to worry about name confusion, just use the names of cues in your library and it will work as expected when the library is used. Names of cues that do not belong to the library will not be available in expressions (see Foo in the example above), however, names of other libraries in the file are available when referencing them in the ref attribute.
297 297  
298 298  Notes:
... ... @@ -327,7 +327,7 @@
327 327  </cue>
328 328  {{/code}}
329 329  
330 -The values (including default values) can be variable expressions and will be evaluated when the cue is enabled, i.e. when it starts checking the conditions. They will be available to the cue as variables, using the parameter name with a '$' prefix. In the example above, the variables $foo, $bar, and $baz would be created.
332 +The values (including default values) can be variable expressions and will be evaluated when the cue is enabled, i.e. when it starts checking the conditions. They will be available to the cue as variables, using the parameter name with a ΓÇÿ$' prefix. In the example above, the variables $foo, $bar, and $baz would be created.
331 331  
332 332  {{code language="xml"}}
333 333  <library name="Lib">
... ... @@ -362,6 +362,8 @@
362 362  This sub-section requires basic knowledge of script expressions.
363 363  {{/info}}
364 364  
367 +
368 +
365 365  In case of instances with sub-instances, you will often want to access a related instance from the current one. Like in the non-instance case, you can simply write the cue name in an expression to reference that cue. However, you should be aware of the pitfalls that are accompanied by this.
366 366  
367 367  When you use a cue name from the same script in an expression, it will always be resolved to some cue - usually a static cue, even if it is still in the disabled state, but it can also be an instance, if it is "related" to the current one.
... ... @@ -397,7 +397,7 @@
397 397  
398 398  * **Conditions with results:** If the instantiating cue has conditions with results, those results are stored in variables - but in the variables of the static cue, not of the instance! So in the <actions> you have to access the variables via the **static **keyword:
399 399  
400 -{{code language="xml"}}<debug_text text="static.$foo"/>{{/code}}
404 +{{code language="xml"}} <debug_text text="static.$foo"/>{{/code}}
401 401  It may even be necessary to copy the variables over to the instance because the static variables can be overwritten by the next condition check:
402 402  {{code language="xml"}}<set_value name="$foo" exact="static.$foo"/>{{/code}}
403 403  
... ... @@ -408,20 +408,22 @@
408 408  
409 409  Most of the attribute values in actions and conditions are interpreted as script expressions and parsed accordingly. An expression is a phrase that can be evaluated to a single value. The simplest expressions are actual numeric values and strings, so called **literals:**
410 410  
411 -* {{code language="xml"}}0{{/code}}(integer number)
412 -* {{code language="xml"}}0772{{/code}}(leading 0 means octal integer number)
413 -* {{code language="xml"}}3.14159{{/code}}(floating point number)
414 -* {{code language="xml"}}5e12{{/code}}(float in exponent notation, "times ten to the power of")
415 -* {{code language="xml"}}0xCAFE{{/code}}(hexadecimal integer number)
415 +* {{code language="xml"}}0{{/code}} (integer number)
416 +* {{code language="xml"}}0772{{/code}} (leading 0 means octal integer number)
417 +* {{code language="xml"}}3.14159{{/code}} (floating point number)
418 +* {{code language="xml"}}5e12{{/code}} (float in exponent notation, "times ten to the power of")
419 +* {{code language="xml"}}0xCAFE{{/code}} (hexadecimal integer number)
416 416  
417 417  {{info}}
418 418  Since octal numbers are hardly ever used (usually unknowingly), the parser is will produce a warning if an octal number is encountered."
419 419  {{/info}}
420 420  
425 +
426 +
421 421  You can write string literals by putting the string in single quotes:
422 422  
423 423  * {{code language="xml"}}'Hello world'{{/code}}
424 -* {{code language="xml"}}''{{/code}}(empty string)
430 +* {{code language="xml"}}''{{/code}} (empty string)
425 425  * {{code language="xml"}}'String with a line break\n'{{/code}}
426 426  
427 427  {{info}}
... ... @@ -433,12 +433,12 @@
433 433  
434 434  Numbers can have a suffix that determines their numeric type. There are also numerical data types like "money" or "time" which can only be expressed by using an appropriate unit suffix:
435 435  
436 -* {{code language="xml"}}5000000000L{{/code}}(large integer)
437 -* {{code language="xml"}}1f{{/code}}(floating point number, same as 1.0, just 1 would be an integer)
438 -* {{code language="xml"}}1000Cr{{/code}}(Money in Credits, converted to 100000 cents automatically)
439 -* {{code language="xml"}}500m{{/code}}(Length in metres)
440 -* {{code language="xml"}}10s{{/code}}(Time in seconds)
441 -* {{code language="xml"}}1h{{/code}}(Time in hours, which is converted to 3600s automatically)
442 +* {{code language="xml"}}5000000000L{{/code}} (large integer)
443 +* {{code language="xml"}}1f{{/code}} (floating point number, same as 1.0, just 1 would be an integer)
444 +* {{code language="xml"}}1000Cr{{/code}} (Money in Credits, converted to 100000 cents automatically)
445 +* {{code language="xml"}}500m{{/code}} (Length in metres)
446 +* {{code language="xml"}}10s{{/code}} (Time in seconds)
447 +* {{code language="xml"}}1h{{/code}} (Time in hours, which is converted to 3600s automatically)
442 442  
443 443  A space between number and suffix is allowed.
444 444  
... ... @@ -495,10 +495,10 @@
495 495  |true|constant|{{code language="xml"}}null == 0{{/code}}|{{code language="xml"}}true{{/code}}|Integer value 1, useful in Boolean expressions
496 496  |pi|constant|{{code language="xml"}}2 * pi{{/code}}|{{code language="xml"}}6.2831853rad{{/code}}|╧Ç as an angle (same as 180deg)
497 497  |()|delimiter|{{code language="xml"}}(2 + 4) * (6 + 1){{/code}}|{{code language="xml"}}42{{/code}}|Parentheses for arithmetic grouping
498 -|[]|delimiter|{{code language="xml"}}[1, 2, 2+1, 'string']{{/code}}|{{code language="xml"}}[1, 2, 3, 'string']{{/code}}|[[List>>doc:||anchor="HLists" style="outline-width: 0px !important; user-select: auto !important;"]] of values
499 -|table[]|delimiter|{{code language="xml"}}table[$foo='bar', {1+1}=40+2]{{/code}}|{{code language="xml"}}table[$foo='bar', {2}=42]{{/code}}|[[Table>>doc:||anchor="HTables" style="outline-width: 0px !important; user-select: auto !important;"]] of values
504 +|[]|delimiter|{{code language="xml"}}[1, 2, 2+1, 'string']{{/code}}|{{code language="xml"}}[1, 2, 3, 'string']{{/code}}|[[List>>MediaWiki.NULL]] of values
505 +|table[]|delimiter|{{code language="xml"}}table[$foo='bar', {1+1}=40+2]{{/code}}|{{code language="xml"}}table[$foo='bar', {2}=42]{{/code}}|[[Table>>MediaWiki.NULL]] of values
500 500  |{}|delimiter|{{code language="xml"}}{101, 3}{{/code}}|{{code language="xml"}}'Some text'{{/code}}|Text lookup (page ID and text ID) from TextDB
501 -\\(Note: Braces are also used for [[property lookups>>doc:||anchor="HValueproperties" style="outline-width: 0px !important; user-select: auto !important;"]])
507 +\\(Note: Braces are also used for [[property lookups>>MediaWiki.NULL]])
502 502  |+|unary|{{code language="xml"}}+21 * (+2){{/code}}|{{code language="xml"}}42{{/code}}|Denotes positive number (no effect)
503 503  |-|unary|{{code language="xml"}}-(21 * -2){{/code}}|{{code language="xml"}}42{{/code}}|Negates the following number
504 504  |not|unary|{{code language="xml"}}not (21 == 42){{/code}}|{{code language="xml"}}true{{/code}}|Yields true if the following expression is false (equal to zero), false otherwise
... ... @@ -508,7 +508,7 @@
508 508  \\{{code language="xml"}}typeof 'Hello world'{{/code}}|
509 509  {{code language="xml"}}datatype.null{{/code}}
510 510  \\{{code language="xml"}}datatype.integer{{/code}}
511 -\\{{code language="xml"}}datatype.string{{/code}}|Yields the [[data type of the following sub-expression>>||anchor="typeof" style="outline-width: 0px !important; user-select: auto !important;"]]
517 +\\{{code language="xml"}}datatype.string{{/code}}|Yields the [[data type of the following sub-expression>>MediaWiki.NULL]]
512 512  |sin|unary|
513 513  {{code language="xml"}}sin(30deg){{/code}}
514 514  \\{{code language="xml"}}sin(pi){{/code}}|
... ... @@ -518,41 +518,7 @@
518 518  {{code language="xml"}}cos(60deg){{/code}}
519 519  \\{{code language="xml"}}cos(pi){{/code}}|
520 520  {{code language="xml"}}0.5{{/code}}
521 -\\{{code language="xml"}}-1.0{{/code}}|Cosine (function-style, parentheses required)
522 -|tan|unary|
523 -{{code language="xml"}}tan(-45deg){{/code}}
524 -\\{{code language="xml"}}tan(45deg){{/code}}|
525 -{{code language="xml"}}-1.0{{/code}}
526 -\\{{code language="xml"}}1.0{{/code}}|(((
527 -Tangent (function-style, parentheses required)
528 -
529 -Available from X4 v7.0
530 -)))
531 -|asin|unary|
532 -{{code language="xml"}}asin(-0.5f){{/code}}
533 -\\{{code language="xml"}}asin(1){{/code}}|
534 -{{code language="xml"}}-0.523599rad{{/code}}
535 -\\{{code language="xml"}}1.5708rad{{/code}}|(((
536 -Inverse sine (function-style, parentheses required)
537 -
538 -Available from X4 v7.0
539 -)))
540 -|acos|unary|
541 -{{code language="xml"}}acos(-0.5f){{/code}}
542 -\\{{code language="xml"}}acos(1.0f){{/code}}|
543 -{{code language="xml"}}2.0944rad{{/code}}
544 -\\{{code language="xml"}}0rad{{/code}}|(((
545 -Inverse cosine (function-style, parentheses required)
546 -
547 -Available from X4 v7.0
548 -)))
549 -|atan|unary|
550 -{{code language="xml"}}atan(1.0f){{/code}}|
551 -{{code language="xml"}}0.785398rad{{/code}}|(((
552 -Inverse tangent (function-style, parentheses required)
553 -
554 -Available from X4 v7.0
555 -)))
527 +\\{{code language="xml"}}0.0{{/code}}|Cosine (function-style, parentheses required)
556 556  |sqrt|unary|{{code language="xml"}}sqrt(2){{/code}}|{{code language="xml"}}1.414213LF{{/code}}|Square root (function-style, parentheses required)
557 557  |exp|unary|{{code language="xml"}}exp(1){{/code}}|{{code language="xml"}}2.71828LF{{/code}}|Exponential function (function-style, parentheses required)
558 558  |log|unary|{{code language="xml"}}log(8) / log(2){{/code}}|{{code language="xml"}}3.0LF{{/code}}|Natural logarithm (function-style, parentheses required)
... ... @@ -570,22 +570,26 @@
570 570  |-|binary|{{code language="xml"}}1 - 1{{/code}}|{{code language="xml"}}0{{/code}}|Subtraction
571 571  |
572 572  lt
573 -\\&lt; (<)|binary|
574 -{{code language="xml"}}1 lt 3{{/code}}|{{code language="xml"}}true{{/code}}|Less than
545 +\\< (<)|binary|
546 +{{code language="xml"}}1 lt 3{{/code}}
547 +\\{{code language="xml"}}1 < 3{{/code}}|{{code language="xml"}}true{{/code}}|Less than
575 575  |
576 576  le
577 -\\&lt;=|binary|
578 -{{code language="xml"}}1 le 3{{/code}}|{{code language="xml"}}true{{/code}}|Less than or equal to
550 +\\<=|binary|
551 +{{code language="xml"}}1 le 3{{/code}}
552 +\\{{code language="xml"}}1 <= 3{{/code}}|{{code language="xml"}}true{{/code}}|Less than or equal to
579 579  |
580 580  gt
581 -\\&gt; (>)|binary|
582 -{{code language="xml"}}1 gt 3{{/code}}|{{code language="xml"}}false{{/code}}|Greater than
555 +\\> (>)|binary|
556 +{{code language="xml"}}1 gt 3{{/code}}
557 +\\{{code language="xml"}}1 < 3{{/code}}|{{code language="xml"}}false{{/code}}|Greater than
583 583  |
584 584  ge
585 -\\&gt;=|binary|
586 -{{code language="xml"}}1 ge 3{{/code}}|{{code language="xml"}}false{{/code}}|Greater than or equal to
560 +\\>=|binary|
561 +{{code language="xml"}}1 ge 3{{/code}}
562 +\\{{code language="xml"}}1 <= 3{{/code}}|{{code language="xml"}}false{{/code}}|Greater than or equal to
587 587  |(((
588 -
564 += =
589 589  )))|binary|{{code language="xml"}}1 + 1 == 2.0{{/code}}|{{code language="xml"}}true{{/code}}|Equal to
590 590  |~!=|binary|{{code language="xml"}}1 + 1 != 2.0{{/code}}|{{code language="xml"}}false{{/code}}|Not equal to
591 591  |and|binary|{{code language="xml"}}true and false{{/code}}|{{code language="xml"}}false{{/code}}|Logical AND (short-circuit semantics)
... ... @@ -627,8 +627,8 @@
627 627  
628 628  There is a way to convert a number into a different type manually: You append the corresponding suffix to a sub-expression in parentheses, like this:
629 629  
630 -* {{code language="xml"}}(1 + 1)f{{/code}}⟹ {{code language="xml"}}2f{{/code}} ⟹ {{code language="xml"}}2.0{{/code}}
631 -* {{code language="xml"}}(1h) m / (180deg) i{{/code}}⟹ {{code language="xml"}}(3600s) m / (3.14rad) i{{/code}} ⟹ {{code language="xml"}}3600m / 3{{/code}} ⟹ {{code language="xml"}}1200m{{/code}}
606 +* {{code language="xml"}}(1 + 1)f{{/code}} ⟹ {{code language="xml"}}2f{{/code}} ⟹ {{code language="xml"}}2.0{{/code}}
607 +* {{code language="xml"}}(1h) m / (180deg) i{{/code}} ⟹ {{code language="xml"}}(3600s) m / (3.14rad) i{{/code}} ⟹ {{code language="xml"}}3600m / 3{{/code}} ⟹ {{code language="xml"}}1200m{{/code}}
632 632  
633 633  When converting to a non-default unit type, this means you interpret the number as in the given units: "{{code language="xml"}}(1km + 500m)h{{/code}}" means that you interpret 1500m as 1500 hours, so the resulting value will be 1500x3600 seconds. (As stated above, the default unit for a length is metres.)
634 634  
... ... @@ -636,8 +636,8 @@
636 636  
637 637  Every data type can be combined with a string with the + operator, and will be converted to a string representation. That way you can also concatenate strings and numbers:
638 638  
639 -* {{code language="xml"}}'One plus one is equal to ' + (1+1) + '.'{{/code}}⟹ {{code language="xml"}}'One plus one is equal to 2.'{{/code}}
640 -* {{code language="xml"}}'One plus one is not equal to ' + 1 + 1 + '.'{{/code}}⟹ {{code language="xml"}}'One plus one is not equal to 11.'{{/code}}
615 +* {{code language="xml"}}'One plus one is equal to ' + (1+1) + '.'{{/code}} ⟹ {{code language="xml"}}'One plus one is equal to 2.'{{/code}}
616 +* {{code language="xml"}}'One plus one is not equal to ' + 1 + 1 + '.'{{/code}} ⟹ {{code language="xml"}}'One plus one is not equal to 11.'{{/code}}
641 641  
642 642  As you can see, operators of the same precedence (+ in this case) are always evaluated from left to right.
643 643  
... ... @@ -652,26 +652,29 @@
652 652  * "and" and "or" use short-circuit semantics: The right side of the operation can be skipped if the left side already determines the outcome of the operation
653 653  ** Example:{{code language="xml"}} false and $foo{{/code}} ⟹ {{code language="xml"}}false{{/code}} (the value of $foo is not checked at all)
654 654  * Unlike != and ==, the comparison operators <, <=, >, >= are only supported **for numeric values**, **difficulty levels**, and **attention levels**. Comparing other non-numeric values will result in an error and an undefined result.
655 -* <, <=, >, >= cannot be used in XML directly, so lt, le, gt, ge are provided as alternatives. In some cases you won't have to use them, though - using [[range checks>>doc:||anchor="HValuecomparisons"]] with additional XML attributes can be more readable.
631 +* <, <=, >, >= cannot be used in XML directly, so lt, le, gt, ge are provided as alternatives. In some cases you won't have to use them, though - using [[range checks>>MediaWiki.NULL]] with additional XML attributes can be more readable.
656 656  
657 -== (% id="categorybroken_macroanchorstrings-and-formatting" %)Strings and formatting(%%) ==
633 +(% id="categorybroken_macroanchorstrings-and-formatting" %)== Strings and formatting==
658 658  
635 +
636 +{{{==}}}
637 +
659 659  You can concatenate string literals using the + operator, but there is also a printf-like formatting syntax, which is easier to use than concatenating lots of small pieces:
660 660  
661 661  * {{code language="xml"}}'The %1 %2 %3 jumps over the %5 %4'.['quick', 'brown', 'fox', 'dog', 'lazy']{{/code}}
662 662  * {{code language="xml"}}'%1 + %2 = %3'.[$a, $b, $a + $b]{{/code}}
663 663  
664 -See also the section about [[value properties>>doc:||anchor="HValueproperties" style="outline-width: 0px !important; user-select: auto !important;"]].
643 +See also the section about [[value properties>>MediaWiki.NULL]].
665 665  
666 -Instead of '%1 %2 %3', you can also use '%s %s %s', which is also compatible with Lua string formatting in the UI system. However, this should only be used if you are sure that the order is the same in all supported languages. If you want to make translators aware that they can change the order of parameters, you should prefer '%1 %2 %3'.
645 +Instead of ΓÇÿ%1 %2 %3', you can also use ΓÇÿ%s %s %s', which is also compatible with Lua string formatting in the UI system. However, this should only be used if you are sure that the order is the same in all supported languages. If you want to make translators aware that they can change the order of parameters, you should prefer '%1 %2 %3'.
667 667  \\To get a percent character in the result string, use '%%' in the format string.
668 668  \\\\\\If you need a more sophisticated method for text substitution, try **<substitute_text>**. See the XML schema documentation for this script action.
669 669  \\**[New as of X Rebirth 4.0]**
670 670  \\ With the formatting syntax above, it is even possible to control how the parameter is formatted, using modifiers between "%" and the parameter specifier ("s" or the parameter number):
671 671  
672 -* {{code language="xml"}}'%,s'.[12345678]{{/code}}⟹ {{code language="xml"}}'12,345,678'{{/code}} (the "," modifier shows a number with thousands separators, correctly localised)
673 -* {{code language="xml"}}'%.3s'.[123.4]{{/code}}⟹ {{code language="xml"}}'123.400'{{/code}} (show 3 fractional digits, rounding half away from zero - decimal point correctly localised)
674 -* {{code language="xml"}}'%,.1s'.[12345.67]'{{/code}}⟹ {{code language="xml"}}'12,345.7'{{/code}} (combination of the above)
651 +* {{code language="xml"}}'%,s'.[12345678]{{/code}} ⟹ {{code language="xml"}}'12,345,678'{{/code}} (the "," modifier shows a number with thousands separators, correctly localised)
652 +* {{code language="xml"}}'%.3s'.[123.4]{{/code}} ⟹ {{code language="xml"}}'123.400'{{/code}} (show 3 fractional digits, rounding half away from zero - decimal point correctly localised)
653 +* {{code language="xml"}}'%,.1s'.[12345.67]'{{/code}} ⟹ {{code language="xml"}}'12,345.7'{{/code}} (combination of the above)
675 675  
676 676  Additional remarks:
677 677  
... ... @@ -680,14 +680,14 @@
680 680  * "." must be followed by a single digit (0-9). In case of ".0" any fractional digits are discarded (rounding towards zero, not half away from zero).
681 681  
682 682  {{info}}
683 -There are also special methods to [[format money values and time values>>doc:||anchor="HMoneyandtimeformatting" style="outline-width: 0px !important; user-select: auto !important;"]] using the "formatted" property.
662 +There are also special methods to [[NULL|format money values and time values]] using the "formatted" property.
684 684  {{/info}}
685 685  
686 686  == Lists ==
687 687  
688 -Another example for a non-numeric value is a list: It is an ordered collection of other arbitrary values (called array or vector in other languages). It can be constructed within an expression using the [[~[~] syntax>>doc:||anchor="HOperators"]]. It may also be generated by special actions and conditions, and there are actions that can [[insert or remove values>>doc:||anchor="HCreatingandremovingvariables" style="outline-width: 0px !important; user-select: auto !important;"]].
667 +Another example for a non-numeric value is a list: It is an ordered collection of other arbitrary values (called array or vector in other languages). It can be constructed within an expression using the [[~[~] syntax>>MediaWiki.NULL]]. It may also be generated by special actions and conditions, and there are actions that can [[insert or remove values>>MediaWiki.NULL]].
689 689  
690 -A list can contain values of arbitrary data types, even mixed in the same list - so a list can actually contain other lists. However, some of the things that you can do with lists require that all contained elements are of a certain type. The contents of a list can be accessed via properties, see the section about [[value properties>>doc:||anchor="HValueproperties"]]. Lists can be empty, these are written as "[ ]".
669 +A list can contain values of arbitrary data types, even mixed in the same list - so a list can actually contain other lists. However, some of the things that you can do with lists require that all contained elements are of a certain type. The contents of a list can be accessed via properties, see the section about [[value properties>>MediaWiki.NULL]]. Lists can be empty, these are written as "[ ]".
691 691  
692 692  {{info}}
693 693  When accessing a list's elements, the numbering is '''1-based''', so the first element has number 1. This is intuitive but different from 0-based numbering in most programming languages."
... ... @@ -706,25 +706,23 @@
706 706  (% id="categorybroken_macroanchortables" %)
707 707  == Tables ==
708 708  
709 -Tables are associative arrays - they are like lists, but you can assign values to (almost) arbitrary keys, not just to index numbers. A table is constructed within an expression using the [[table~[~] syntax>>doc:||anchor="HOperators" style="outline-width: 0px !important; user-select: auto !important;"]]. See the section about [[value properties>>doc:||anchor="HValueproperties" style="outline-width: 0px !important; user-select: auto !important;"]] for how to access the contents of a table. [[Creating and removing entries>>doc:||anchor="HCreatingandremovingvariables" style="outline-width: 0px !important; user-select: auto !important;"]] works similarly to lists, but instead of inserting, you simply assign a value to a table key. If the key does not exist yet, it will be created.
688 +Tables are associative arrays - they are like lists, but you can assign values to (almost) arbitrary keys, not just to index numbers. A table is constructed within an expression using the [[table~[~] syntax>>MediaWiki.NULL]]. See the section about [[value properties>>MediaWiki.NULL]] for how to access the contents of a table. [[Creating and removing entries>>MediaWiki.NULL]] works similarly to lists, but instead of inserting, you simply assign a value to a table key. If the key does not exist yet, it will be created.
710 710  
711 711  Almost all values are allowed as table keys, but there are a few exceptions:
712 712  
713 713  * Strings must start with '$', like variables
714 714  * null cannot be used as table key (but the number 0 is valid)
715 -* Lists, tables, groups, buildplans, loadouts and constructionsequences cannot be used as table keys
694 +* Lists, tables, groups and buildplans cannot be used as table keys
716 716  
717 717  These restrictions only apply to the keys, there are no restrictions for values that you assign to them. For example:
718 718  
719 -* {{code language="xml"}}table[]{{/code}}⟹ creates an empty table
720 -* {{code language="xml"}}table[{0} = null]{{/code}}⟹ creates a table that maps the number 0 to null
698 +* {{code language="xml"}}table[]{{/code}} ⟹ creates an empty table
699 +* {{code language="xml"}}table[{0} = null]{{/code}} ⟹ creates a table that maps the number 0 to null
721 721  
722 -* {{code language="xml"}}table[{'$foo'} = 'bar']{{/code}}⟹ a table that maps the string '$foo' to the string 'bar'
723 -* {{code language="xml"}}table[$foo = 'bar']{{/code}}⟹ exactly the same, just a shorter notation for string keys
724 -* {{code language="xml"}}table[foo = 'bar']{{/code}}⟹ error, 'foo' does not start with a '$'
725 -* {{code language="xml"}}table[{1} = [], {2} = table[]] {{/code}}⟹ a table that maps 1 to an empty list and 2 to an empty table
726 -* {{code language="xml"}}table[faction.argon = 'bar']{{/code}}⟹ error, the expression faction.argon will not be resolved into a key value. Requires { } braces.
727 -* {{code language="xml"}}table[{faction.argon} = 'bar'] {{/code}}⟹ a table that maps the value faction.argon to the string 'bar'
701 +* {{code language="xml"}}table[{'$foo'} = 'bar']{{/code}} ⟹ a table that maps the string '$foo' to the string 'bar'
702 +* {{code language="xml"}}table[$foo = 'bar']{{/code}} ⟹ exactly the same, just a shorter notation for string keys
703 +* {{code language="xml"}}table[foo = 'bar']{{/code}} ⟹ error, 'foo' does not start with a '$'
704 +* {{code language="xml"}}table[{1} = [], {2} = table[]] {{/code}} ⟹ a table that maps 1 to an empty list and 2 to an empty table
728 728  
729 729  Just like lists, tables are stored as references, so it's possible that multiple variables reference the same table (see above).
730 730  
... ... @@ -745,10 +745,10 @@
745 745  
746 746  You can look up a property by appending a dot and the key in curly braces:
747 747  
748 -* {{code language="xml"}}[100, 200, 300, 400].{1}{{/code}}⟹ 100 (reading the first element)
749 -* {{code language="xml"}}[100, 200, ['Hello ', 'world']] .{3}.{2}{{/code}}⟹ 'world' (second element of the inner list, which is the third element of the outer list)
750 -* {{code language="xml"}}[].{'count'}{{/code}}⟹ 0
751 -* {{code language="xml"}}table[{21} = 42].{21}{{/code}}⟹ 42
725 +* {{code language="xml"}}[100, 200, 300, 400].{1}{{/code}} ⟹ 100 (reading the first element)
726 +* {{code language="xml"}}[100, 200, ['Hello ', 'world']] .{3}.{2}{{/code}} ⟹ 'world' (second element of the inner list, which is the third element of the outer list)
727 +* {{code language="xml"}}[].{'count'}{{/code}} ⟹ 0
728 +* {{code language="xml"}}table[{21} = 42].{21}{{/code}} ⟹ 42
752 752  
753 753  In most cases the property key is a fixed string, like "name" or "class". You can write this like above:
754 754  
... ... @@ -772,19 +772,19 @@
772 772  
773 773  **min'** and '**max'** return the minimum or maximum (all elements have to be numeric)
774 774  
775 -* {{code language="xml"}}[1, 6, 8].min{{/code}}⟹ 1
752 +* {{code language="xml"}}[1, 6, 8].min{{/code}} ⟹ 1
776 776  
777 777  **average'** returns the average (but all element types have to be compatible)
778 778  
779 -* {{code language="xml"}}[1, 6, 8].average{{/code}}⟹ 5
756 +* {{code language="xml"}}[1, 6, 8].average{{/code}} ⟹ 5
780 780  
781 781  **indexof'** is followed by another property, and the index of the first occurence of that key in the list is returned, or 0 if it's not in the list
782 782  
783 -* {{code language="xml"}}[1, 6, 8].indexof.{8}{{/code}}⟹ 3
760 +* {{code language="xml"}}[1, 6, 8].indexof.{8}{{/code}} ⟹ 3
784 784  
785 785  **clone'** creates a shallow copy of the list (i.e. lists that are contained as elements in the list are not copied, only the reference to them)
786 786  
787 -* {{code language="xml"}}[1, 6, 8].clone{{/code}}⟹ {{code language="xml"}}[1, 6, 8]{{/code}}
764 +* {{code language="xml"}}[1, 6, 8].clone{{/code}} ⟹ {{code language="xml"}}[1, 6, 8]{{/code}}
788 788  
789 789  A table has different properties:
790 790  
... ... @@ -801,7 +801,7 @@
801 801  * {{code language="xml"}}$table.keys.random{{/code}}: A randomly chosen key (which requires that the table is non-empty)
802 802  
803 803  {{info}}
804 -The string formatting syntax that you have seen [[above>>doc:||anchor="HStringsandformatting" style="outline-width: 0px !important; user-select: auto !important;"]] is also based on the property system. You basically pass a list as property key to a string. Braces around the brackets are not required, so 'foo'.[...] is just a convenient alternative notation for 'foo'.{[...]}.
781 +The string formatting syntax that you have seen [[NULL|above]] is also based on the property system. You basically pass a list as property key to a string. Braces around the brackets are not required, so 'foo'.[...] is just a convenient alternative notation for 'foo'.{[...]}.
805 805  {{/info}}
806 806  
807 807  === (% id="lookup-tests-and-suppressing-errors" %)Lookup tests and suppressing errors(%%) ===
... ... @@ -808,20 +808,20 @@
808 808  
809 809  If you look up a property that does not exist, there will be an error, and the result will be null. To test whether a property exists, you can append a question mark "?" to the lookup, which yields true or false:
810 810  
811 -* {{code language="xml"}}$list.{5}{{/code}}⟹ The fifth element of a list - however, if $list has less than 5 elements (and if it's also not a table with the key 5), there will be an error
812 -* {{code language="xml"}}$list.{5}?{{/code}}⟹ true if $list exists and has the property 5, false otherwise
813 -* {{code language="xml"}}$table.$key?{{/code}}⟹ Analogously, true if $table exists and has the string property '$key'
788 +* {{code language="xml"}}$list.{5}{{/code}} ⟹ The fifth element of a list - however, if $list has less than 5 elements (and if it's also not a table with the key 5), there will be an error
789 +* {{code language="xml"}}$list.{5}?{{/code}} ⟹ true if $list exists and has the property 5, false otherwise
790 +* {{code language="xml"}}$table.$key?{{/code}} ⟹ Analogously, true if $table exists and has the string property '$key'
814 814  
815 815  The question mark can even be applied to variables:
816 816  
817 -* {{code language="xml"}}$list{{/code}}⟹ The value stored under the name $list, or an error if there is no such variable
818 -* {{code language="xml"}}$list?{{/code}}⟹ true if the variable exists, false otherwise
794 +* {{code language="xml"}}$list{{/code}} ⟹ The value stored under the name $list, or an error if there is no such variable
795 +* {{code language="xml"}}$list?{{/code}} ⟹ true if the variable exists, false otherwise
819 819  
820 820  To look up the value of a property although it may not exist, you can use the at-sign "@" as prefix:
821 821  
822 -* {{code language="xml"}}@$list.{5}{{/code}}⟹ The result of the $list lookup if $list exists and has the property 5, otherwise null (without error message)
823 -* {{code language="xml"}}@$list{{/code}}⟹ The list if this variable exists, null otherwise
824 -* {{code language="xml"}}@$list.{5}.{1}{{/code}}⟹ The first element of the fifth element of $list, if it exists, null otherwise
799 +* {{code language="xml"}}@$list.{5}{{/code}} ⟹ The result of the $list lookup if $list exists and has the property 5, otherwise null (without error message)
800 +* {{code language="xml"}}@$list{{/code}} ⟹ The list if this variable exists, null otherwise
801 +* {{code language="xml"}}@$list.{5}.{1}{{/code}} ⟹ The first element of the fifth element of $list, if it exists, null otherwise
825 825  
826 826  As you can see, an error is already prevented if any link in the property chain does not exist. But use the @ prefix with care, since error messages are really helpful for detecting problems in your scripts. The @ prefix only suppresses property-related error messages and does not change any in-game behaviour.
827 827  
... ... @@ -853,11 +853,11 @@
853 853  |profile|
854 854  profile.flat
855 855  \\profile.increasing
856 -\\profile.bell|Probability distribution profile (see [[random ranges>>doc:||anchor="HRandomranges" style="outline-width: 0px !important; user-select: auto !important;"]])
833 +\\profile.bell|Probability distribution profile (see [[random ranges>>MediaWiki.NULL]])
857 857  |cuestate|
858 858  cuestate.waiting
859 859  \\cuestate.active
860 -\\cuestate.complete|[[Cue states>>||anchor="HCues" style="outline-width: 0px !important; user-select: auto !important;"]]
837 +\\cuestate.complete|[[Cue states>>MediaWiki.NULL]]
861 861  |level|
862 862  level.easy
863 863  \\level.medium
... ... @@ -877,8 +877,6 @@
877 877  \\faction.argongovernment|Factions
878 878  )))
879 879  
880 -{{id name="typeof"/}}
881 -
882 882  {{info}}
883 883  With the ''typeof'' operator you can get the datatype of any expression and compare it with what you expect, for example:
884 884  
... ... @@ -926,13 +926,13 @@
926 926  === (% id="categorybroken_macroanchormoney-and-time-formatting" %)Money and time formatting(%%) ===
927 927  
928 928  **[New as of X Rebirth 4.0]**
929 -\\Numbers don't have any properties, except for money and time: They have a "**formatted**" property, which allows you to get a custom string representation with more advanced options than the [[generic formatting method>>||anchor="HStringsandformatting" style="outline-width: 0px !important; user-select: auto !important;"]] for numbers.
904 +\\Numbers don't have any properties, except for money and time: They have a "**formatted**" property, which allows you to get a custom string representation with more advanced options than the [[generic formatting method>>MediaWiki.NULL]] for numbers.
930 930  
931 931  * {{code language="xml"}}$money.formatted.{'formatstring'}{{/code}}
932 -* {{code language="xml"}}$money.formatted.default{{/code}}(using default format string '%s')
907 +* {{code language="xml"}}$money.formatted.default{{/code}} (using default format string '%s')
933 933  
934 934  * {{code language="xml"}}$time.formatted.{'formatstring'}{{/code}}
935 -* {{code language="xml"}}$time.formatted.default{{/code}}(using default format string '%T')
910 +* {{code language="xml"}}$time.formatted.default{{/code}} (using default format string '%T')
936 936  
937 937  In scripts, money is stored in cents, not Credits. The formatted representation always shows the value in Credits, including thousands separators.
938 938  
... ... @@ -962,14 +962,14 @@
962 962  * {{code language="xml"}}(1234Cr).formatted.{'%1s'}{{/code}}⟹{{code language="xml"}}'1 k'{{/code}} (rounding towards zero)
963 963  * {{code language="xml"}}(1234Cr).formatted.{'%cM'}{{/code}}⟹{{code language="xml"}}'0 M'{{/code}}
964 964  
965 -For documentation of time format strings, see the Lua function ConvertTimeString() in the [[Lua function overview>>doc:X Rebirth Wiki.Modding support.UI Modding support.Lua function overview.WebHome||style="outline-width: 0px !important; user-select: auto !important;"]].
940 +For documentation of time format strings, see the Lua function ConvertTimeString() in the [[MediaWiki.ARCHIVE.XRWIKIModding_supportUI_Modding_supportLua_function_overview]].
966 966  
967 967  Examples:
968 968  
969 -* {{code language="xml"}}(151s).formatted.{'%T'}{{/code}}⟹ {{code language="xml"}}'00:02:31'{{/code}}
970 -* {{code language="xml"}}(151s).formatted.default{{/code}}⟹ {{code language="xml"}}'00:02:31'{{/code}} (same as {'%T'})
971 -* {{code language="xml"}}(151s).formatted.{'%.3T'}{{/code}}⟹ {{code language="xml"}}'00:02:31.000'{{/code}}
972 -* {{code language="xml"}}(151s).formatted.{'%h:%M'}{{/code}}⟹ {{code language="xml"}}'0:02'{{/code}}
944 +* {{code language="xml"}}(151s).formatted.{'%T'}{{/code}} ⟹ {{code language="xml"}}'00:02:31'{{/code}}
945 +* {{code language="xml"}}(151s).formatted.default{{/code}} ⟹ {{code language="xml"}}'00:02:31'{{/code}} (same as {'%T'})
946 +* {{code language="xml"}}(151s).formatted.{'%.3T'}{{/code}} ⟹ {{code language="xml"}}'00:02:31.000'{{/code}}
947 +* {{code language="xml"}}(151s).formatted.{'%h:%M'}{{/code}} ⟹ {{code language="xml"}}'0:02'{{/code}}
973 973  
974 974  === Complete property documentation ===
975 975  
... ... @@ -981,7 +981,7 @@
981 981  scriptproperties.html has to load files from different folders, which modern browsers do not allow by default for security reasons. In order to open scriptproperties.html, the following is required:
982 982  
983 983  * Firefox: On the about:config page, the value of "security.fileuri.strict_origin_policy" has to be changed to "false".
984 -* Chrome: The Chrome launcher has to be started with the command-line parameter --~-~---allow-file-access-from-files
959 +* Chrome: The Chrome launcher has to be started with the command-line parameter --allow-file-access-from-files--
985 985  {{/info}}
986 986  
987 987  This provides you with a complete list of all supported "base keywords" and properties. To filter in this list, you can enter an expression in the text field:
... ... @@ -1006,7 +1006,6 @@
1006 1006  
1007 1007  * MD scripts and cues are identified by their names. So a script can only be refreshed if it has the same script name as before (file name is irrelevant).
1008 1008  * If there are new script files or new cue nodes (i.e. scripts/cues with new names) they are created and added properly. If you remove script files or cue nodes, the corresponding scripts/cues are removed from the game, including instances.
1009 -** (!) Pitfall: It is recommended that cues are not removed if they were previously released in public builds, to prevent future cues with the same name leading to errors (see example below). Instead they can be emptied and marked as deprecated.
1010 1010  * As a consequence, you CANNOT rename scripts or cues if you want to refresh them. Doing so would remove the old script or cue and add a new one with the new name.
1011 1011  * You CANNOT change a <cue> to a <library> or vice versa.
1012 1012  * You CANNOT add, remove, or change the "ref" attribute of a cue. But it is possible to remove the whole cue. (If all references to a library are removed you can also remove the library itself.)
... ... @@ -1028,34 +1028,6 @@
1028 1028  When adding a variable in a new MD script version and using that variable in multiple places, be aware that the variable doesn't exist yet in older savegames. You may have to check the existence of the variable before accessing it, or add some patch logic that initiailses the variable after loading the savegame, if necessary.
1029 1029  {{/warning}}
1030 1030  
1031 -{{warning}}
1032 -(% id="cke_bm_221021S" style="display:none" %) (%%)Cue Removal Pitfall:
1033 -If you remove a cue and then later add another cue with the same name, old save files will not know that the cue has been removed inbetween. In the following example the first cue was created setting $val_1 and the game is saved.
1034 -{{code language="xml"}}<cue name="Deprecated_Test1">
1035 - <actions>
1036 - <set_value name="$val_1" exact="'old value'"/>
1037 - <debug_text text="$val_1"/>
1038 - </actions>
1039 -</cue>{{/code}}
1040 -\\If the Cue is deleted and years later a new cue with the same name appears, the old save will consider the new cue as already completed without executing its actions. The Cue PrintValue will fail to find a variable set up in its parent.
1041 -{{code language="xml"}}<cue name="Deprecated_Test1">
1042 - <actions>
1043 - <set_value name="$val_2" exact="'new value'"/>
1044 - <debug_text text="$val_2"/>
1045 - </actions>
1046 - <cues>
1047 - <cue name="PrintValue">
1048 - <actions>
1049 - <debug_text text="$val_2"/>
1050 - </actions>
1051 - </cue>
1052 - </cues>
1053 -</cue>{{/code}}
1054 -\\To avoid this, do not delete any cues (once they are public for save game compatibility), but empty them out and mark them as deprecated. This will prevent new cues with the same name in the script.
1055 -{{code language="xml"}}<!-- Deprecated Cues, kept to not duplicate names in future cues -->
1056 -<cue name="Deprecated_Test1" comment="deprecated"></cue>{{/code}}
1057 -{{/warning}}
1058 -
1059 1059  == Patching ==
1060 1060  
1061 1061  Cues can have **<patch>** elements with actions that will be performed when an old savegame is loaded. To control which savegames should be affected, you can add a //**version **//attribute to the <cue> node and a //**sinceversion**// attribute in the patch. When a cue is loaded from a savegame that has an older version than //sinceversion//, the <patch> actions will be performed immediately after loading.
... ... @@ -1134,6 +1134,7 @@
1134 1134   <set_value name="$foo" min="-20" max="20" profile="profile.increasing" scale="4"/>
1135 1135  {{/code}}
1136 1136  
1083 +
1137 1137  = Variables and namespaces =
1138 1138  
1139 1139  As you have seen above, you can easily access variables by writing their name (including $ prefix) in an expression. Namespaces define in which cue the variables are actually stored (and from which cue they are read).
... ... @@ -1188,6 +1188,7 @@
1188 1188  
1189 1189  Removing an entry from a list shifts all following elements down by one. If you want to clear an entry without removing it from the list, just use <set_value> instead.
1190 1190  
1138 +
1191 1191  == Accessing remote variables ==
1192 1192  
1193 1193  You can also read and write variables in other cues by using the variable name as property key: