2022-12-15 03:29:56 -05:00
|
|
|
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
|
2022-12-15 16:08:32 -05:00
|
|
|
if currentScenario ~= object.getDescription() then
|
|
|
|
currentScenario = object.getDescription()
|
|
|
|
fireScenarioChangedEvent()
|
|
|
|
end
|
2022-12-15 03:29:56 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function fireScenarioChangedEvent()
|
2022-12-15 16:08:32 -05:00
|
|
|
log("Firing")
|
2022-12-15 03:29:56 -05:00
|
|
|
playAreaApi.onScenarioChanged(currentScenario)
|
|
|
|
end
|