Changes for page Mission Director Guide

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

From version 32970.1
edited by Owen Lake
on 2023/10/10 15:22
Change comment: There is no comment for this version
To version 32970.13
edited by Heinrich Unrau
on 2024/10/17 12:58
Change comment: There is no comment for this version

Summary

Details

Page properties
Author
... ... @@ -1,1 +1,1 @@
1 -xwiki:XWiki.Owen
1 +xwiki:XWiki.Heinrich
Content
... ... @@ -407,11 +407,11 @@
407 407  
408 408  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:**
409 409  
410 -* {{code language="xml"}}0{{/code}} (integer number)
411 -* {{code language="xml"}}0772{{/code}} (leading 0 means octal integer number)
412 -* {{code language="xml"}}3.14159{{/code}} (floating point number)
413 -* {{code language="xml"}}5e12{{/code}} (float in exponent notation, "times ten to the power of")
414 -* {{code language="xml"}}0xCAFE{{/code}} (hexadecimal integer number)
410 +* {{code language="xml"}}0{{/code}}(integer number)
411 +* {{code language="xml"}}0772{{/code}}(leading 0 means octal integer number)
412 +* {{code language="xml"}}3.14159{{/code}}(floating point number)
413 +* {{code language="xml"}}5e12{{/code}}(float in exponent notation, "times ten to the power of")
414 +* {{code language="xml"}}0xCAFE{{/code}}(hexadecimal integer number)
415 415  
416 416  {{info}}
417 417  Since octal numbers are hardly ever used (usually unknowingly), the parser is will produce a warning if an octal number is encountered."
... ... @@ -420,7 +420,7 @@
420 420  You can write string literals by putting the string in single quotes:
421 421  
422 422  * {{code language="xml"}}'Hello world'{{/code}}
423 -* {{code language="xml"}}''{{/code}} (empty string)
423 +* {{code language="xml"}}''{{/code}}(empty string)
424 424  * {{code language="xml"}}'String with a line break\n'{{/code}}
425 425  
426 426  {{info}}
... ... @@ -432,12 +432,12 @@
432 432  
433 433  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:
434 434  
435 -* {{code language="xml"}}5000000000L{{/code}} (large integer)
436 -* {{code language="xml"}}1f{{/code}} (floating point number, same as 1.0, just 1 would be an integer)
437 -* {{code language="xml"}}1000Cr{{/code}} (Money in Credits, converted to 100000 cents automatically)
438 -* {{code language="xml"}}500m{{/code}} (Length in metres)
439 -* {{code language="xml"}}10s{{/code}} (Time in seconds)
440 -* {{code language="xml"}}1h{{/code}} (Time in hours, which is converted to 3600s automatically)
435 +* {{code language="xml"}}5000000000L{{/code}}(large integer)
436 +* {{code language="xml"}}1f{{/code}}(floating point number, same as 1.0, just 1 would be an integer)
437 +* {{code language="xml"}}1000Cr{{/code}}(Money in Credits, converted to 100000 cents automatically)
438 +* {{code language="xml"}}500m{{/code}}(Length in metres)
439 +* {{code language="xml"}}10s{{/code}}(Time in seconds)
440 +* {{code language="xml"}}1h{{/code}}(Time in hours, which is converted to 3600s automatically)
441 441  
442 442  A space between number and suffix is allowed.
443 443  
... ... @@ -518,21 +518,40 @@
518 518  \\{{code language="xml"}}cos(pi){{/code}}|
519 519  {{code language="xml"}}0.5{{/code}}
520 520  \\{{code language="xml"}}-1.0{{/code}}|Cosine (function-style, parentheses required)
521 -|tan|unary|{{code language="xml"}}tan(-45deg){{/code}}(((
521 +|tan|unary|
522 +{{code language="xml"}}tan(-45deg){{/code}}
523 +\\{{code language="xml"}}tan(45deg){{/code}}|
524 +{{code language="xml"}}-1.0{{/code}}
525 +\\{{code language="xml"}}1.0{{/code}}|(((
526 +Tangent (function-style, parentheses required)
522 522  
523 -{{code language="xml"}}tan(45deg){{/code}}
524 -)))|(((
525 -(% id="cke_bm_767206S" style="display:none" %) {{code language="xml"}}-1.0{{/code}}
528 +Available from X4 v7.0
529 +)))
530 +|asin|unary|
531 +{{code language="xml"}}asin(-0.5f){{/code}}
532 +\\{{code language="xml"}}asin(1){{/code}}|
533 +{{code language="xml"}}-0.523599rad{{/code}}
534 +\\{{code language="xml"}}1.5708rad{{/code}}|(((
535 +Inverse sine (function-style, parentheses required)
526 526  
527 -{{code language="xml"}}
528 -1.0
529 -{{/code}}
530 -)))|Tangent (function-style, parentheses required)
531 -|asin|unary|{{code language="xml"}}asin(-0.5f){{/code}}{{code language="xml"}}asin(1){{/code}}|{{code language="xml"}}-0.523599rad{{/code}}(((
532 -
533 -))){{code language="xml" width="70"}}1.5708rad{{/code}}|Inverse sine (function-style, parentheses required)
534 -|acos|unary|{{code language="xml"}}acos(0.5f){{/code}}{{code language="xml"}}acos(1.0f){{/code}}|{{code language="xml"}}asin(2.0944rad){{/code}}{{code language="xml"}}0rad{{/code}}|Inverse cosine (function-style, parentheses required)
535 -|atan|unary| | |Inverse tangent (function-style, parentheses required)
537 +Available from X4 v7.0
538 +)))
539 +|acos|unary|
540 +{{code language="xml"}}acos(-0.5f){{/code}}
541 +\\{{code language="xml"}}acos(1.0f){{/code}}|
542 +{{code language="xml"}}2.0944rad{{/code}}
543 +\\{{code language="xml"}}0rad{{/code}}|(((
544 +Inverse cosine (function-style, parentheses required)
545 +
546 +Available from X4 v7.0
547 +)))
548 +|atan|unary|
549 +{{code language="xml"}}atan(1.0f){{/code}}|
550 +{{code language="xml"}}0.785398rad{{/code}}|(((
551 +Inverse tangent (function-style, parentheses required)
552 +
553 +Available from X4 v7.0
554 +)))
536 536  |sqrt|unary|{{code language="xml"}}sqrt(2){{/code}}|{{code language="xml"}}1.414213LF{{/code}}|Square root (function-style, parentheses required)
537 537  |exp|unary|{{code language="xml"}}exp(1){{/code}}|{{code language="xml"}}2.71828LF{{/code}}|Exponential function (function-style, parentheses required)
538 538  |log|unary|{{code language="xml"}}log(8) / log(2){{/code}}|{{code language="xml"}}3.0LF{{/code}}|Natural logarithm (function-style, parentheses required)
... ... @@ -611,8 +611,8 @@
611 611  
612 612  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:
613 613  
614 -* {{code language="xml"}}(1 + 1)f{{/code}} ⟹ {{code language="xml"}}2f{{/code}} ⟹ {{code language="xml"}}2.0{{/code}}
615 -* {{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}}
633 +* {{code language="xml"}}(1 + 1)f{{/code}}⟹ {{code language="xml"}}2f{{/code}} ⟹ {{code language="xml"}}2.0{{/code}}
634 +* {{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}}
616 616  
617 617  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.)
618 618  
... ... @@ -620,8 +620,8 @@
620 620  
621 621  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:
622 622  
623 -* {{code language="xml"}}'One plus one is equal to ' + (1+1) + '.'{{/code}} ⟹ {{code language="xml"}}'One plus one is equal to 2.'{{/code}}
624 -* {{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}}
642 +* {{code language="xml"}}'One plus one is equal to ' + (1+1) + '.'{{/code}}⟹ {{code language="xml"}}'One plus one is equal to 2.'{{/code}}
643 +* {{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}}
625 625  
626 626  As you can see, operators of the same precedence (+ in this case) are always evaluated from left to right.
627 627  
... ... @@ -653,9 +653,9 @@
653 653  \\**[New as of X Rebirth 4.0]**
654 654  \\ 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):
655 655  
656 -* {{code language="xml"}}'%,s'.[12345678]{{/code}} ⟹ {{code language="xml"}}'12,345,678'{{/code}} (the "," modifier shows a number with thousands separators, correctly localised)
657 -* {{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)
658 -* {{code language="xml"}}'%,.1s'.[12345.67]'{{/code}} ⟹ {{code language="xml"}}'12,345.7'{{/code}} (combination of the above)
675 +* {{code language="xml"}}'%,s'.[12345678]{{/code}}⟹ {{code language="xml"}}'12,345,678'{{/code}} (the "," modifier shows a number with thousands separators, correctly localised)
676 +* {{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)
677 +* {{code language="xml"}}'%,.1s'.[12345.67]'{{/code}}⟹ {{code language="xml"}}'12,345.7'{{/code}} (combination of the above)
659 659  
660 660  Additional remarks:
661 661  
... ... @@ -700,13 +700,13 @@
700 700  
701 701  These restrictions only apply to the keys, there are no restrictions for values that you assign to them. For example:
702 702  
703 -* {{code language="xml"}}table[]{{/code}} ⟹ creates an empty table
704 -* {{code language="xml"}}table[{0} = null]{{/code}} ⟹ creates a table that maps the number 0 to null
722 +* {{code language="xml"}}table[]{{/code}}⟹ creates an empty table
723 +* {{code language="xml"}}table[{0} = null]{{/code}}⟹ creates a table that maps the number 0 to null
705 705  
706 -* {{code language="xml"}}table[{'$foo'} = 'bar']{{/code}} ⟹ a table that maps the string '$foo' to the string 'bar'
707 -* {{code language="xml"}}table[$foo = 'bar']{{/code}} ⟹ exactly the same, just a shorter notation for string keys
708 -* {{code language="xml"}}table[foo = 'bar']{{/code}} ⟹ error, 'foo' does not start with a '$'
709 -* {{code language="xml"}}table[{1} = [], {2} = table[]] {{/code}} ⟹ a table that maps 1 to an empty list and 2 to an empty table
725 +* {{code language="xml"}}table[{'$foo'} = 'bar']{{/code}}⟹ a table that maps the string '$foo' to the string 'bar'
726 +* {{code language="xml"}}table[$foo = 'bar']{{/code}}⟹ exactly the same, just a shorter notation for string keys
727 +* {{code language="xml"}}table[foo = 'bar']{{/code}}⟹ error, 'foo' does not start with a '$'
728 +* {{code language="xml"}}table[{1} = [], {2} = table[]] {{/code}}⟹ a table that maps 1 to an empty list and 2 to an empty table
710 710  
711 711  Just like lists, tables are stored as references, so it's possible that multiple variables reference the same table (see above).
712 712  
... ... @@ -727,10 +727,10 @@
727 727  
728 728  You can look up a property by appending a dot and the key in curly braces:
729 729  
730 -* {{code language="xml"}}[100, 200, 300, 400].{1}{{/code}} ⟹ 100 (reading the first element)
731 -* {{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)
732 -* {{code language="xml"}}[].{'count'}{{/code}} ⟹ 0
733 -* {{code language="xml"}}table[{21} = 42].{21}{{/code}} ⟹ 42
749 +* {{code language="xml"}}[100, 200, 300, 400].{1}{{/code}}⟹ 100 (reading the first element)
750 +* {{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)
751 +* {{code language="xml"}}[].{'count'}{{/code}}⟹ 0
752 +* {{code language="xml"}}table[{21} = 42].{21}{{/code}}⟹ 42
734 734  
735 735  In most cases the property key is a fixed string, like "name" or "class". You can write this like above:
736 736  
... ... @@ -754,19 +754,19 @@
754 754  
755 755  **min'** and '**max'** return the minimum or maximum (all elements have to be numeric)
756 756  
757 -* {{code language="xml"}}[1, 6, 8].min{{/code}} ⟹ 1
776 +* {{code language="xml"}}[1, 6, 8].min{{/code}}⟹ 1
758 758  
759 759  **average'** returns the average (but all element types have to be compatible)
760 760  
761 -* {{code language="xml"}}[1, 6, 8].average{{/code}} ⟹ 5
780 +* {{code language="xml"}}[1, 6, 8].average{{/code}}⟹ 5
762 762  
763 763  **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
764 764  
765 -* {{code language="xml"}}[1, 6, 8].indexof.{8}{{/code}} ⟹ 3
784 +* {{code language="xml"}}[1, 6, 8].indexof.{8}{{/code}}⟹ 3
766 766  
767 767  **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)
768 768  
769 -* {{code language="xml"}}[1, 6, 8].clone{{/code}} ⟹ {{code language="xml"}}[1, 6, 8]{{/code}}
788 +* {{code language="xml"}}[1, 6, 8].clone{{/code}}⟹ {{code language="xml"}}[1, 6, 8]{{/code}}
770 770  
771 771  A table has different properties:
772 772  
... ... @@ -790,20 +790,20 @@
790 790  
791 791  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:
792 792  
793 -* {{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
794 -* {{code language="xml"}}$list.{5}?{{/code}} ⟹ true if $list exists and has the property 5, false otherwise
795 -* {{code language="xml"}}$table.$key?{{/code}} ⟹ Analogously, true if $table exists and has the string property '$key'
812 +* {{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
813 +* {{code language="xml"}}$list.{5}?{{/code}}⟹ true if $list exists and has the property 5, false otherwise
814 +* {{code language="xml"}}$table.$key?{{/code}}⟹ Analogously, true if $table exists and has the string property '$key'
796 796  
797 797  The question mark can even be applied to variables:
798 798  
799 -* {{code language="xml"}}$list{{/code}} ⟹ The value stored under the name $list, or an error if there is no such variable
800 -* {{code language="xml"}}$list?{{/code}} ⟹ true if the variable exists, false otherwise
818 +* {{code language="xml"}}$list{{/code}}⟹ The value stored under the name $list, or an error if there is no such variable
819 +* {{code language="xml"}}$list?{{/code}}⟹ true if the variable exists, false otherwise
801 801  
802 802  To look up the value of a property although it may not exist, you can use the at-sign "@" as prefix:
803 803  
804 -* {{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)
805 -* {{code language="xml"}}@$list{{/code}} ⟹ The list if this variable exists, null otherwise
806 -* {{code language="xml"}}@$list.{5}.{1}{{/code}} ⟹ The first element of the fifth element of $list, if it exists, null otherwise
823 +* {{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)
824 +* {{code language="xml"}}@$list{{/code}}⟹ The list if this variable exists, null otherwise
825 +* {{code language="xml"}}@$list.{5}.{1}{{/code}}⟹ The first element of the fifth element of $list, if it exists, null otherwise
807 807  
808 808  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.
809 809  
... ... @@ -911,10 +911,10 @@
911 911  \\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.
912 912  
913 913  * {{code language="xml"}}$money.formatted.{'formatstring'}{{/code}}
914 -* {{code language="xml"}}$money.formatted.default{{/code}} (using default format string '%s')
933 +* {{code language="xml"}}$money.formatted.default{{/code}}(using default format string '%s')
915 915  
916 916  * {{code language="xml"}}$time.formatted.{'formatstring'}{{/code}}
917 -* {{code language="xml"}}$time.formatted.default{{/code}} (using default format string '%T')
936 +* {{code language="xml"}}$time.formatted.default{{/code}}(using default format string '%T')
918 918  
919 919  In scripts, money is stored in cents, not Credits. The formatted representation always shows the value in Credits, including thousands separators.
920 920  
... ... @@ -948,10 +948,10 @@
948 948  
949 949  Examples:
950 950  
951 -* {{code language="xml"}}(151s).formatted.{'%T'}{{/code}} ⟹ {{code language="xml"}}'00:02:31'{{/code}}
952 -* {{code language="xml"}}(151s).formatted.default{{/code}} ⟹ {{code language="xml"}}'00:02:31'{{/code}} (same as {'%T'})
953 -* {{code language="xml"}}(151s).formatted.{'%.3T'}{{/code}} ⟹ {{code language="xml"}}'00:02:31.000'{{/code}}
954 -* {{code language="xml"}}(151s).formatted.{'%h:%M'}{{/code}} ⟹ {{code language="xml"}}'0:02'{{/code}}
970 +* {{code language="xml"}}(151s).formatted.{'%T'}{{/code}}⟹ {{code language="xml"}}'00:02:31'{{/code}}
971 +* {{code language="xml"}}(151s).formatted.default{{/code}}⟹ {{code language="xml"}}'00:02:31'{{/code}} (same as {'%T'})
972 +* {{code language="xml"}}(151s).formatted.{'%.3T'}{{/code}}⟹ {{code language="xml"}}'00:02:31.000'{{/code}}
973 +* {{code language="xml"}}(151s).formatted.{'%h:%M'}{{/code}}⟹ {{code language="xml"}}'0:02'{{/code}}
955 955  
956 956  === Complete property documentation ===
957 957  
... ... @@ -963,7 +963,7 @@
963 963  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:
964 964  
965 965  * Firefox: On the about:config page, the value of "security.fileuri.strict_origin_policy" has to be changed to "false".
966 -* Chrome: The Chrome launcher has to be started with the command-line parameter --allow-file-access-from-files--
985 +* Chrome: The Chrome launcher has to be started with the command-line parameter --~-~---allow-file-access-from-files
967 967  {{/info}}
968 968  
969 969  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:
... ... @@ -988,6 +988,27 @@
988 988  
989 989  * 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).
990 990  * 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.
1010 +** 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. 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 fi
1011 +{{code language="xml"}}<cue name="Deprecated_Test1" namespace="this">
1012 + <actions>
1013 + <set_value name="$val_1" exact="'old value'"/>
1014 + <debug_text text="$val_1"/>
1015 + </actions>
1016 +</cue>
1017 +
1018 +<cue name="Deprecated_Test1" namespace="this">
1019 + <actions>
1020 + <set_value name="$val_2" exact="'new value'"/>
1021 + <debug_text text="$val_2"/>
1022 + </actions>
1023 + <cues>
1024 + <cue name="PrintValue">
1025 + <actions>
1026 + <debug_text text="parent.$val_2"/>
1027 + </actions>
1028 + </cue>
1029 + </cues>
1030 +</cue>{{/code}}
991 991  * 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.
992 992  * You CANNOT change a <cue> to a <library> or vice versa.
993 993  * 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.)