added action spawning ability

This commit is contained in:
dscarpac 2024-05-01 08:24:22 -05:00
parent 7ad53e2192
commit ac09b737cb
3 changed files with 2314 additions and 1 deletions

View File

@ -19,7 +19,8 @@
"Horror.36be72",
"Path.7234af",
"Resource.910e09",
"ResourceCounter.498ec0"
"ResourceCounter.498ec0",
"Neutral.04765c"
],
"ContainedObjects_path": "TokenSource.124381",
"Description": "",

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,9 @@
local playmatApi = require("playermat/PlaymatApi")
local searchLib = require("util/SearchLib")
local tokenManager = require("core/token/TokenManager")
local TOKEN_INDEX = {}
TOKEN_INDEX[1] = "actionToken"
TOKEN_INDEX[3] = "resourceCounter"
TOKEN_INDEX[4] = "damage"
TOKEN_INDEX[5] = "path"
@ -20,6 +23,15 @@ local stateTable = {
["offering"] = 8
}
local actionStateTable = {
["Guardian"] = 1,
["Seeker"] = 2,
["Rogue"] = 3,
["Mystic"] = 4,
["Survivor"] = 5,
["Neutral"] = 6
}
---@param index number Index of the pressed key
---@param playerColor string Color of the triggering player
function onScriptingButtonDown(index, playerColor)
@ -74,6 +86,21 @@ function onScriptingButtonDown(index, playerColor)
end
end
end
-- check for nearest investigator card and change action token state to its class
elseif tokenType == "actionToken" then
local matColor = playmatApi.getMatColorByPosition(position)
local result = playmatApi.searchAroundPlaymat(matColor, "isCard")
for j, card in ipairs(result) do
local metadata = JSON.decode(card.getGMNotes()) or {}
if metadata.type == "Investigator" then
investigatorClass = metadata.class
end
end
local stateID = actionStateTable[investigatorClass]
if stateID ~= nil and stateID ~= 6 then
callback = function(spawned) spawned.setState(stateID) end
end
end
tokenManager.spawnToken(position, tokenType, rotation, callback)