Merge pull request #222 from argonui/adding-more-APIs

Adding MythosAreaAPI
This commit is contained in:
Chr1Z 2023-03-04 18:28:32 +01:00 committed by GitHub
commit 3e20f7f6e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 29 additions and 13 deletions

View File

@ -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

View File

@ -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

View File

@ -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,

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