expanded custom token support

This commit is contained in:
Chr1Z93 2024-04-03 21:24:30 +02:00
parent 5eb5b1e840
commit a95dc0ea58

View File

@ -296,10 +296,10 @@ function drawChaosToken(params)
-- add the token to the list, compute new position based on list length
tokenOffset[1] = tokenOffset[1] + (0.17 * #chaosTokens)
local token
if params.guidToBeResolved then -- resolve a sealed token from a card
local token
-- resolve a sealed token from a card
if params.guidToBeResolved then
token = getObjectFromGUID(params.guidToBeResolved)
token.setPositionSmooth(params.mat.positionToWorld(tokenOffset))
local guid = token.getGUID()
@ -308,24 +308,28 @@ function drawChaosToken(params)
blessCurseManagerApi.releasedToken(tokenType, guid)
end
tokenArrangerApi.layout()
else -- take a token from the bag, either specified or random
-- take a token from the bag, either specified or random
else
local takeParameters = {
position = params.mat.positionToWorld(tokenOffset),
rotation = params.mat.getRotation()
}
if params.tokenType then
for i, lookedForToken in ipairs(chaosBag.getObjects()) do
if lookedForToken.name == params.tokenType then
takeParameters.index = i - 1
end
for i, lookedForToken in ipairs(chaosBag.getObjects()) do
if lookedForToken.nickname == params.tokenType then
takeParameters.index = i - 1
end
end
end
token = chaosBag.takeObject(takeParameters)
end
end
-- get data for token description
local name = token.getName()
if name == "" then name = "Custom" end
local tokenData = mythosAreaApi.returnTokenData().tokenData or {}
local specificData = tokenData[name] or {}
token.setDescription(specificData.description or "")