SCED/src/core/MythosArea.ttslua

34 lines
862 B
Plaintext
Raw Normal View History

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
if currentScenario ~= object.getDescription() then
currentScenario = object.getDescription()
fireScenarioChangedEvent()
end
end
end
function fireScenarioChangedEvent()
log("Firing")
playAreaApi.onScenarioChanged(currentScenario)
end