--- title: MD libraries: reuse a cue template summary: Library, ref and parameters: one template with different input values. section: scripting kind: guide status: example updated: 2026-10-27 tags: ["X4","modding","md","libraries"] sources: ["https://wiki.egosoft.com/X%20Rebirth%20Wiki/Modding%20support/Mission%20Director%20Guide/"] --- ## What a library is A `library` defines a cue template; a referencing `cue ref` creates its use. It is not a Lua function. Required parameters have no `default`; the user supplies `param` without a `params` wrapper. ## Complete independent example ```xml ``` ## What happens With fresh script state, Small calculates 5 and Large calculates 12. `debug_text` sends these values to the diagnostic log with [script output enabled](wiki:debugging). Their message order is unspecified. This example has not been executed in game. Exercise: change only Small's Amount. Its expected result should change without editing the template or Large's inputs. ## Scope Parameters become `$Amount` and `$Offset` when the cue is enabled. Use qualified `ref="md.ScriptName.LibraryName"` for another script. Behavior attributes on a referencing cue do not override the template: except for its name, behavior comes from the library. Updating an enabled cue requires [save/load checks](wiki:md-persistence). Egosoft's shared guide describes XR/X4 MD structure; verify the actual action set against X4. Continue with [cues](wiki:md-cues) and [variables](wiki:md-variables).