--- title: Mission Director cues and events summary: MD script structure, repeatable handlers and reasons a cue may not fire. section: scripting kind: guide status: example updated: 2026-10-27 tags: ["X4","modding","md","cues"] sources: ["https://wiki.egosoft.com/X%20Rebirth%20Wiki/Modding%20support/Mission%20Director%20Guide/"] --- ## 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](wiki:md-variables). ```xml ``` ## 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. ```xml ``` ## 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. XSD validity does not establish successful import or execution. Use conditional blocks to limit actions; do not transplant library mechanisms into regular cues without checking their contracts. The [library/ref example](wiki:md-libraries) explains template reuse. ## 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](wiki:md-lua-bridge) and [game testing](wiki:testing).