automatically set description of chaos tokens

This commit is contained in:
Chr1Z93 2023-03-06 13:20:09 +01:00
parent 1f49718fae
commit 99ed76417e
2 changed files with 14 additions and 2 deletions

View File

@ -33,6 +33,7 @@ local hideTitleSplashWaitFunctionId = nil
local playmatApi = require("playermat/playmatApi") local playmatApi = require("playermat/playmatApi")
local tokenManager = require("core/token/TokenManager") local tokenManager = require("core/token/TokenManager")
local playAreaAPI = require("core/PlayAreaApi") local playAreaAPI = require("core/PlayAreaApi")
local mythosAreaApi = require("core/MythosAreaApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenArrangerApi = require("accessories/TokenArrangerApi")
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
@ -300,7 +301,15 @@ function drawChaosToken(params)
position = mat.positionToWorld(tokenOffset), position = mat.positionToWorld(tokenOffset),
rotation = mat.getRotation() rotation = mat.getRotation()
}) })
trackChaosToken(token.getName(), mat.getGUID())
-- get data for token description
local name = token.getName()
local tokenData = mythosAreaApi.returnTokenData().tokenData or {}
local specificData = tokenData[name] or {}
token.setDescription(specificData.description or "")
-- track the chaos token (for stat tracker and future returning)
trackChaosToken(name, mat.getGUID())
chaosTokens[#chaosTokens + 1] = token chaosTokens[#chaosTokens + 1] = token
return return
else else

View File

@ -62,7 +62,10 @@ function onCollisionEnter(collisionInfo)
-- trigger update if a change was detected and push new data -- trigger update if a change was detected and push new data
if updateNeeded then if updateNeeded then
local metadata = JSON.decode(object.getGMNotes()) or {} local metadata = JSON.decode(object.getGMNotes()) or {}
if not metadata["tokens"] then return end if not metadata["tokens"] then
tokenData = {}
return
end
tokenData = metadata["tokens"][(useFrontData and "front" or "back")] tokenData = metadata["tokens"][(useFrontData and "front" or "back")]
fireTokenDataChangedEvent() fireTokenDataChangedEvent()
end end