32 lines
822 B
Plaintext
32 lines
822 B
Plaintext
|
local playAreaApi = require("core/PlayAreaApi")
|
||
|
|
||
|
local currentScenario
|
||
|
|
||
|
function onLoad(saveState)
|
||
|
if saveState ~= nil then
|
||
|
local loadedState = JSON.decode(saveState) or { }
|
||
|
currentScenario = loadedState.currentScenario
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function onSave()
|
||
|
return JSON.encode({
|
||
|
currentScenario = currentScenario
|
||
|
})
|
||
|
end
|
||
|
|
||
|
-- TTS event handler. Checks for a scenrio card, extracts the scenario name from the description,
|
||
|
-- and fires it to the relevant listeners.
|
||
|
function onCollisionEnter(collisionInfo)
|
||
|
local object = collisionInfo.collision_object
|
||
|
if object.getName() == "Scenario" then
|
||
|
log("Collision: " .. object.getGUID())
|
||
|
currentScenario = object.getDescription()
|
||
|
fireScenarioChangedEvent()
|
||
|
end
|
||
|
end
|
||
|
|
||
|
function fireScenarioChangedEvent()
|
||
|
playAreaApi.onScenarioChanged(currentScenario)
|
||
|
end
|