Let entering a room run a script
GAME EVENTS
You can ask PCA3D to call your code when something happens. Here, every arrival adds one to a running count and writes the room ID to the output.
In room_arrivals, Keep global instance alive retains the count for this play session. OnSceneLoaded subscribes the record to room arrivals.
local Script = {}
local arrivals = 0function Script.on_scene_loaded(event)
arrivals = arrivals + 1
Log("Arrival " .. arrivals .. " in " .. tostring(event.sceneId))
endfunction Script.run(context)
return arrivals
endreturn ScriptThe first arrival starts at zero and adds one. On entering the second room, the same script instance still holds one, so the next arrival becomes two. Checking an event and defining its matching function are both part of the hookup.
In the capture, the room IDs were lab and roof. The output read Arrival 1 in lab, then Arrival 2 in roof. Use a PCA variable such as archive_open for progress a player needs after loading a game.
Lua scripting / Illustrated guide W13
