Script structure#
MD handlers live under mdscript → cues → cue, with effects in actions. A cue without conditions can perform brief initialization. The standalone template below initializes a cue-owned variable; see variable scope.
<mdscript name="WikiExample">
<cues>
<cue name="Init">
<actions>
<set_value name="$Count" exact="0" />
</actions>
</cue>
</cues>
</mdscript>Event handler#
Insert the UI event handler below inside cues. instantiate=true permits repeated events to use separate instances. Do not put unrelated requests' mutable state in a shared variable without an explicit reason.
<cue name="Read" instantiate="true" namespace="this">
<conditions>
<event_ui_triggered screen="'WikiExample'" control="'read'" />
</conditions>
<actions>
<set_value name="$Payload" exact="event.param3" />
<debug_text text="'Wiki read request received'" />
</actions>
</cue>A condition without an event#
A bare check_value condition needs an appropriate checking mode, such as checkinterval or onfail, according to the cue contract. A missing mode passed XSD but was rejected by the game parser in project research. return is not a universal exit from a regular cue: the inspected X4 9.00 scenario rejected it. Conditional blocks limited execution; result returns stayed within the relevant library.
Debugging#
Distinguish file loading, event reception and the actual effect. A log line answers only the question it was designed to observe. See Lua ↔ MD and game testing.