MISSION SCRIPTING

Quick reference

A whole script

local missions = require("missions")
local mission = require(missions.MY_SCENARIO)

return {
    initial_state = mission.states.STATE_X,
    on_start = function(context, state) end,
    on_load = function(context, state) end,
    on_event_region_changed = function(context, state, event) end,
    on_event_player_trigger = function(context, state, event) end,
    on_event_squad_state = function(context, state, event) end,
    on_event_timer_elapsed = function(context, state, event) end,
    on_event_effect_result = function(context, state, event) end,
}

Every entry is optional. See How a script runs.

The calls you need most

tocall
remember a valuecontext:set_variable(name, value) / state:variable(name)
waitcontext:start_timer(name, ms)
spawn enemiescontext:squad(Squad.X):place{}
open a doorcontext:slot(Slot.D_X):transition{transition = context.sdk.device_transitions.open}
show a goalcontext:slot(Slot.M_DIRECTIVE_SENSOR_X):set_directive{directive = mission.Directive.X}
play a linecontext:slot(Slot.M_DIALOG_SENSOR_X):play_dialogue_cue{cue = n}
watch a triggercontext:slot(Slot.PT_X):fire_trigger() then on_event_player_trigger
check a clearcontext:cohort{squads = {...}}.cleared
change areacontext:select_state(mission.states.STATE_X)
finishcontext:complete_mission{}

The full list is in the Lua API reference. For worked examples, see Recipes.

Where things are

Paths are inside your game install.

thingplace
your scriptsbin/x64/Sunrise/scripts/<name>/<name>.lua
shared helpersbin/x64/Sunrise/scripts/lib/
generated SDKbin/x64/Sunrise/sdk/lua/
logbin/x64/Sunrise/logs/sunrise.log
settingsbin/x64/Sunrise/settings.json
in-game toolspress Insert