adding MythosAreaAPI

This commit is contained in:
Chr1Z93 2023-03-01 23:35:04 +01:00
parent ceef316adf
commit d7f098fcc5
4 changed files with 29 additions and 13 deletions

View File

@ -1,3 +1,5 @@
local mythosAreaApi = require("core/MythosAreaApi")
-- common parameters -- common parameters
local buttonParameters = {} local buttonParameters = {}
buttonParameters.function_owner = self buttonParameters.function_owner = self
@ -89,10 +91,7 @@ function onLoad(saveState)
end) end)
-- grab token metadata from mythos area -- grab token metadata from mythos area
local mythosArea = getObjectFromGUID("9f334f") Wait.time(function() onTokenDataChanged(mythosAreaApi.returnTokenData()) end, 0.5)
Wait.time(function() mythosArea.call("fireTokenDataChangedEvent") end, 0.5)
Wait.time(layout, 2)
end end
-- delete temporary tokens when destroyed -- delete temporary tokens when destroyed
@ -263,10 +262,10 @@ end
function onTokenDataChanged(parameters) function onTokenDataChanged(parameters)
local tokenData = parameters.tokenData or {} local tokenData = parameters.tokenData or {}
local currentScenario = parameters.currentScenario 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 -- only update if this data is new
local info = currentScenario .. useFrontData local info = currentScenario .. tostring(useFrontData)
if latestLoad == info then return end if latestLoad == info then return end
latestLoad = info latestLoad = info

View File

@ -13,12 +13,8 @@ do
-- updates the token modifiers with the provided data -- updates the token modifiers with the provided data
---@param tokenData Table Contains the chaos token metadata ---@param tokenData Table Contains the chaos token metadata
TokenArrangerApi.onTokenDataChanged = function(tokenData, currentScenario, useFrontData) TokenArrangerApi.onTokenDataChanged = function(fullData)
callIfExistent("onTokenDataChanged", { callIfExistent("onTokenDataChanged", fullData)
tokenData = tokenData,
currentScenario = currentScenario,
useFrontData = useFrontData
})
end end
-- deletes already laid out tokens -- deletes already laid out tokens

View File

@ -91,7 +91,17 @@ end
-- fires if the scenario title or the difficulty changes -- fires if the scenario title or the difficulty changes
function fireTokenDataChangedEvent() 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 end
-- Simple method to check if the given point is in a specified area. Local use only, -- Simple method to check if the given point is in a specified area. Local use only,

View 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