Exchange directions#
| Direction | Function or condition |
|---|---|
| Lua → MD | AddUITriggeredEvent(screen, control, payload) |
| MD receiver | event_ui_triggered, with event.param3 in this contract |
| MD → Lua | raise_lua_event |
| Lua receiver | RegisterEvent(name, callback) |
Names must match exactly. Register the receiver before sending if a reply can arrive immediately.
Lua subscription and request#
The example assumes the UI file is already registered through the manifest. It illustrates the call form, not universal world readiness. In a real mod, send only at an established point in both UI and MD lifecycles.
local received = false
RegisterEvent("Wiki.Pong", function(_, payload)
received = payload == "pong"
end)
AddUITriggeredEvent("WikiBridge", "ping", "hello")MD handling and reply#
Insert this fragment in your script's cues. It matches screen/control, validates the simple hello payload and sends the named pong reply.
<cue name="Ping" instantiate="true" namespace="this">
<conditions>
<event_ui_triggered screen="'WikiBridge'" control="'ping'" />
</conditions>
<actions>
<do_if value="event.param3 == 'hello'">
<raise_lua_event name="'Wiki.Pong'" param="'pong'" />
</do_if>
</actions>
</cue>When an exchange becomes an operation#
Validate input types and object existence before a game effect. Handle repeated clicks separately for actions that create objects or spend money. Show success after actual execution. Assemble complete multipart replies before replacing a displayed list. See custom windows and AddUITriggeredEvent.