adding MythosAreaAPI
This commit is contained in:
parent
ceef316adf
commit
d7f098fcc5
@ -1,3 +1,5 @@
|
||||
local mythosAreaApi = require("core/MythosAreaApi")
|
||||
|
||||
-- common parameters
|
||||
local buttonParameters = {}
|
||||
buttonParameters.function_owner = self
|
||||
@ -89,10 +91,7 @@ function onLoad(saveState)
|
||||
end)
|
||||
|
||||
-- grab token metadata from mythos area
|
||||
local mythosArea = getObjectFromGUID("9f334f")
|
||||
Wait.time(function() mythosArea.call("fireTokenDataChangedEvent") end, 0.5)
|
||||
|
||||
Wait.time(layout, 2)
|
||||
Wait.time(function() onTokenDataChanged(mythosAreaApi.returnTokenData()) end, 0.5)
|
||||
end
|
||||
|
||||
-- delete temporary tokens when destroyed
|
||||
@ -263,10 +262,10 @@ end
|
||||
function onTokenDataChanged(parameters)
|
||||
local tokenData = parameters.tokenData or {}
|
||||
local currentScenario = parameters.currentScenario or ""
|
||||
local useFrontData = parameters.useFrontData or "true"
|
||||
local useFrontData = parameters.useFrontData or true
|
||||
|
||||
-- only update if this data is new
|
||||
local info = currentScenario .. useFrontData
|
||||
local info = currentScenario .. tostring(useFrontData)
|
||||
if latestLoad == info then return end
|
||||
latestLoad = info
|
||||
|
||||
|
@ -13,12 +13,8 @@ do
|
||||
|
||||
-- updates the token modifiers with the provided data
|
||||
---@param tokenData Table Contains the chaos token metadata
|
||||
TokenArrangerApi.onTokenDataChanged = function(tokenData, currentScenario, useFrontData)
|
||||
callIfExistent("onTokenDataChanged", {
|
||||
tokenData = tokenData,
|
||||
currentScenario = currentScenario,
|
||||
useFrontData = useFrontData
|
||||
})
|
||||
TokenArrangerApi.onTokenDataChanged = function(fullData)
|
||||
callIfExistent("onTokenDataChanged", fullData)
|
||||
end
|
||||
|
||||
-- deletes already laid out tokens
|
||||
|
@ -91,7 +91,17 @@ end
|
||||
|
||||
-- fires if the scenario title or the difficulty changes
|
||||
function fireTokenDataChangedEvent()
|
||||
tokenArrangerApi.onTokenDataChanged(tokenData, currentScenario, tostring(useFrontData))
|
||||
local fullData = returnTokenData()
|
||||
tokenArrangerApi.onTokenDataChanged(fullData)
|
||||
end
|
||||
|
||||
-- returns the chaos token metadata (if provided)
|
||||
function returnTokenData()
|
||||
return {
|
||||
tokenData = tokenData,
|
||||
currentScenario = currentScenario,
|
||||
useFrontData = useFrontData
|
||||
}
|
||||
end
|
||||
|
||||
-- Simple method to check if the given point is in a specified area. Local use only,
|
||||
|
11
src/core/MythosAreaApi.ttslua
Normal file
11
src/core/MythosAreaApi.ttslua
Normal file
@ -0,0 +1,11 @@
|
||||
do
|
||||
local MythosAreaApi = {}
|
||||
local MYTHOS_AREA_GUID = "9f334f"
|
||||
|
||||
-- returns the chaos token metadata (if provided through scenario reference card)
|
||||
MythosAreaApi.returnTokenData = function()
|
||||
return getObjectFromGUID("9f334f").call("returnTokenData")
|
||||
end
|
||||
|
||||
return MythosAreaApi
|
||||
end
|
Loading…
Reference in New Issue
Block a user