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
| to | call |
|---|---|
| remember a value | context:set_variable(name, value) / state:variable(name) |
| remember across launches | context:set_flag(name, value) / context:get_flag(name) |
| wait | context:start_timer(name, ms) |
| roll a random number | context:random() |
| spawn enemies | context:squad(Squad.X):place{} |
| spawn placed objects | context:activate_objects{slots = {Slot.O_X, Slot.O_Y}, active = true} |
| open a door | context:slot(Slot.D_X):transition{transition = context.sdk.device_transitions.open} |
| show a goal | context:slot(Slot.M_DIRECTIVE_SENSOR_X):set_directive{directive = mission.Directive.X} |
| show a goal counter | the same, with progress = {current, maximum} on a directive with counter = true |
| play a line | context:slot(Slot.M_DIALOG_SENSOR_X):play_dialogue_cue{cue = n} |
| watch a trigger | context:slot(Slot.PT_X):fire_trigger() then on_event_player_trigger |
| count who is in an area | context:slot(Slot.PM_X):set_occupancy_condition{value = 1} then on_event_trigger_entered and on_event_trigger_exited |
| check a clear | context:cohort{squads = {...}}.cleared |
| change area | context:select_state(mission.states.STATE_X) |
| move the party | context:teleport{region = n, spawn_set_hash = h} |
| start a scene | context:scene(Scene.X):activate{} |
| fire a scene input | context:scene(Scene.X):send_event{key = mission.SceneInput.X.NAME} |
| wait for a scene output | on_event_scene_output, compare event.key with mission.SceneOutput.X.NAME |
| finish | context: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.
| thing | place |
|---|---|
| your scripts | bin/x64/Sunrise/scripts/<name>/<name>.lua |
| a mod’s scripts | bin/x64/Sunrise/mods/<mod>/scripts/<name>/<name>.lua; they replace the base script |
| shared helpers | bin/x64/Sunrise/scripts/lib/ |
| generated SDK | bin/x64/Sunrise/sdk/lua/ |
| log | bin/x64/Sunrise/logs/sunrise.log |
| settings | bin/x64/Sunrise/settings.json |
| in-game tools | press Insert |