made object reference dynamic

This commit is contained in:
Chr1Z93 2023-09-29 12:08:54 +02:00
parent 550c958275
commit 889f0af13f
18 changed files with 138 additions and 143 deletions

View File

@ -83,10 +83,6 @@
{ {
"displayed": "CameraZoom_ignore", "displayed": "CameraZoom_ignore",
"normalized": "camerazoom_ignore" "normalized": "camerazoom_ignore"
},
{
"displayed": "TokenArranger",
"normalized": "tokenarranger"
} }
] ]
} }

View File

@ -36,6 +36,7 @@
"LuaScript": "require(\"chaosbag/BlessCurseManager\")", "LuaScript": "require(\"chaosbag/BlessCurseManager\")",
"LuaScriptState": "false", "LuaScriptState": "false",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"BlessCurseManager\"}",
"Name": "Custom_Token", "Name": "Custom_Token",
"Nickname": "Bless/Curse Manager", "Nickname": "Bless/Curse Manager",
"Snap": true, "Snap": true,

View File

@ -62,6 +62,7 @@
"LuaScript": "require(\"core/MythosArea\")", "LuaScript": "require(\"core/MythosArea\")",
"LuaScriptState": "{\"currentScenario\":\"\",\"tokenData\":[],\"useFrontData\":true}", "LuaScriptState": "{\"currentScenario\":\"\",\"tokenData\":[],\"useFrontData\":true}",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"MythosArea\"}",
"Name": "Custom_Tile", "Name": "Custom_Tile",
"Nickname": "Mythos Area", "Nickname": "Mythos Area",
"Snap": true, "Snap": true,

View File

@ -973,6 +973,7 @@
"LuaScript": "require(\"core/PlayArea\")", "LuaScript": "require(\"core/PlayArea\")",
"LuaScriptState": "{\"trackedLocations\":[]}", "LuaScriptState": "{\"trackedLocations\":[]}",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"PlayArea\"}",
"Name": "Custom_Token", "Name": "Custom_Token",
"Nickname": "Playarea", "Nickname": "Playarea",
"Snap": true, "Snap": true,

View File

@ -343,8 +343,8 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScript": "require(\"playermat/Playmat\")",
"LuaScriptState_path": "Playermat1White.8b081b.luascriptstate", "LuaScriptState_path": "Playermat1White.8b081b.luascriptstate",
"LuaScript_path": "Playermat1White.8b081b.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"White\",\"type\":\"Playermat\"}", "Memo": "{\"matColor\":\"White\",\"type\":\"Playermat\"}",
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -1,11 +0,0 @@
---------------------------------------------------------
-- specific setup (different for each playmat)
---------------------------------------------------------
TRASHCAN_GUID = "147e80"
STAT_TRACKER_GUID = "e598c2"
RESOURCE_COUNTER_GUID = "4406f0"
CLUE_COUNTER_GUID = "d86b7c"
CLUE_CLICKER_GUID = "db85d6"
require("playermat/Playmat")

View File

@ -343,8 +343,8 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScript": "require(\"playermat/Playmat\")",
"LuaScriptState_path": "Playermat2Orange.bd0ff4.luascriptstate", "LuaScriptState_path": "Playermat2Orange.bd0ff4.luascriptstate",
"LuaScript_path": "Playermat2Orange.bd0ff4.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Orange\",\"type\":\"Playermat\"}", "Memo": "{\"matColor\":\"Orange\",\"type\":\"Playermat\"}",
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -1,11 +0,0 @@
---------------------------------------------------------
-- specific setup (different for each playmat)
---------------------------------------------------------
TRASHCAN_GUID = "f7b6c8"
STAT_TRACKER_GUID = "b4a5f7"
RESOURCE_COUNTER_GUID = "816d84"
CLUE_COUNTER_GUID = "1769ed"
CLUE_CLICKER_GUID = "3f22e5"
require("playermat/Playmat")

View File

@ -343,8 +343,8 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScript": "require(\"playermat/Playmat\")",
"LuaScriptState_path": "Playermat3Green.383d8b.luascriptstate", "LuaScriptState_path": "Playermat3Green.383d8b.luascriptstate",
"LuaScript_path": "Playermat3Green.383d8b.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Green\",\"type\":\"Playermat\"}", "Memo": "{\"matColor\":\"Green\",\"type\":\"Playermat\"}",
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -1,11 +0,0 @@
---------------------------------------------------------
-- specific setup (different for each playmat)
---------------------------------------------------------
TRASHCAN_GUID = "5f896a"
STAT_TRACKER_GUID = "af7ed7"
RESOURCE_COUNTER_GUID = "cd15ac"
CLUE_COUNTER_GUID = "032300"
CLUE_CLICKER_GUID = "891403"
require("playermat/Playmat")

View File

@ -343,8 +343,8 @@
"IgnoreFoW": false, "IgnoreFoW": false,
"LayoutGroupSortIndex": 0, "LayoutGroupSortIndex": 0,
"Locked": true, "Locked": true,
"LuaScript": "require(\"playermat/Playmat\")",
"LuaScriptState_path": "Playermat4Red.0840d5.luascriptstate", "LuaScriptState_path": "Playermat4Red.0840d5.luascriptstate",
"LuaScript_path": "Playermat4Red.0840d5.ttslua",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Red\",\"type\":\"Playermat\"}", "Memo": "{\"matColor\":\"Red\",\"type\":\"Playermat\"}",
"Name": "Custom_Tile", "Name": "Custom_Tile",

View File

@ -1,11 +0,0 @@
---------------------------------------------------------
-- specific setup (different for each playmat)
---------------------------------------------------------
TRASHCAN_GUID = "4b8594"
STAT_TRACKER_GUID = "e74881"
RESOURCE_COUNTER_GUID = "a4b60d"
CLUE_COUNTER_GUID = "37be78"
CLUE_CLICKER_GUID = "4111de"
require("playermat/Playmat")

View File

@ -36,13 +36,11 @@
"LuaScript": "require(\"accessories/TokenArranger\")", "LuaScript": "require(\"accessories/TokenArranger\")",
"LuaScriptState_path": "TokenArranger.022907.luascriptstate", "LuaScriptState_path": "TokenArranger.022907.luascriptstate",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"TokenArranger\"}",
"Name": "Custom_Token", "Name": "Custom_Token",
"Nickname": "Token Arranger", "Nickname": "Token Arranger",
"Snap": true, "Snap": true,
"Sticky": true, "Sticky": true,
"Tags": [
"TokenArranger"
],
"Tooltip": true, "Tooltip": true,
"Transform": { "Transform": {
"posX": -42.3, "posX": -42.3,

View File

@ -158,6 +158,7 @@
"LuaScript": "require(\"core/VictoryDisplay\")", "LuaScript": "require(\"core/VictoryDisplay\")",
"LuaScriptState": "", "LuaScriptState": "",
"MeasureMovement": false, "MeasureMovement": false,
"Memo": "{\"matColor\":\"Mythos\",\"type\":\"VictoryDisplay\"}",
"Name": "Custom_Token", "Name": "Custom_Token",
"Nickname": "Victory Display", "Nickname": "Victory Display",
"Snap": false, "Snap": false,

View File

@ -1,11 +1,32 @@
do do
local TokenArrangerApi = {} local TokenArrangerApi = {}
-- gets the first object that matches the provided information
---@param matColor String Color of the playermat
---@param type String Object to look for (usually name without spaces)
local function getObjectFromMemo(matColor, type)
if matColor == nil or type == nil then
return nil
end
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo then
local decoded = JSON.decode(memo) or {}
if decoded.matColor == matColor and decoded.type == type then
return obj
end
end
end
return nil
end
-- local function to call the token arranger, if it is on the table -- local function to call the token arranger, if it is on the table
---@param functionName String Name of the function to cal ---@param functionName String Name of the function to cal
---@param argument Variant Parameter to pass ---@param argument Variant Parameter to pass
local function callIfExistent(functionName, argument) local function callIfExistent(functionName, argument)
local tokenArranger = getObjectsWithTag("TokenArranger")[1] local tokenArranger = getObjectFromMemo("Mythos", "TokenArranger")
if tokenArranger ~= nil then if tokenArranger ~= nil then
tokenArranger.call(functionName, argument) tokenArranger.call(functionName, argument)
end end

View File

@ -1,10 +1,30 @@
do do
local BlessCurseManagerApi = {} local BlessCurseManagerApi = {}
local MANAGER_GUID = "5933fb"
-- gets the first object that matches the provided information
---@param matColor String Color of the playermat
---@param type String Object to look for (usually name without spaces)
local function getObjectFromMemo(matColor, type)
if matColor == nil or type == nil then
return nil
end
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo then
local decoded = JSON.decode(memo) or {}
if decoded.matColor == matColor and decoded.type == type then
return obj
end
end
end
return nil
end
-- removes all taken tokens and resets the counts -- removes all taken tokens and resets the counts
BlessCurseManagerApi.removeTakenTokensAndReset = function() BlessCurseManagerApi.removeTakenTokensAndReset = function()
local BlessCurseManager = getObjectFromGUID(MANAGER_GUID) local BlessCurseManager = getObjectFromMemo("Mythos", "BlessCurseManager")
Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Bless") end, 0.05) Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Bless") end, 0.05)
Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Curse") end, 0.10) Wait.time(function() BlessCurseManager.call("removeTakenTokens", "Curse") end, 0.10)
Wait.time(function() BlessCurseManager.call("doReset", "White") end, 0.15) Wait.time(function() BlessCurseManager.call("doReset", "White") end, 0.15)
@ -12,30 +32,30 @@ do
-- updates the internal count (called by cards that seal bless/curse tokens) -- updates the internal count (called by cards that seal bless/curse tokens)
BlessCurseManagerApi.sealedToken = function(type, guid) BlessCurseManagerApi.sealedToken = function(type, guid)
getObjectFromGUID(MANAGER_GUID).call("sealedToken", { type = type, guid = guid }) getObjectFromMemo("Mythos", "BlessCurseManager").call("sealedToken", { type = type, guid = guid })
end end
-- updates the internal count (called by cards that seal bless/curse tokens) -- updates the internal count (called by cards that seal bless/curse tokens)
BlessCurseManagerApi.releasedToken = function(type, guid) BlessCurseManagerApi.releasedToken = function(type, guid)
getObjectFromGUID(MANAGER_GUID).call("releasedToken", { type = type, guid = guid }) getObjectFromMemo("Mythos", "BlessCurseManager").call("releasedToken", { type = type, guid = guid })
end end
-- broadcasts the current status for bless/curse tokens -- broadcasts the current status for bless/curse tokens
---@param playerColor String Color of the player to show the broadcast to ---@param playerColor String Color of the player to show the broadcast to
BlessCurseManagerApi.broadcastStatus = function(playerColor) BlessCurseManagerApi.broadcastStatus = function(playerColor)
getObjectFromGUID(MANAGER_GUID).call("broadcastStatus", playerColor) getObjectFromMemo("Mythos", "BlessCurseManager").call("broadcastStatus", playerColor)
end end
-- removes all bless / curse tokens from the chaos bag and play -- removes all bless / curse tokens from the chaos bag and play
---@param playerColor String Color of the player to show the broadcast to ---@param playerColor String Color of the player to show the broadcast to
BlessCurseManagerApi.removeAll = function(playerColor) BlessCurseManagerApi.removeAll = function(playerColor)
getObjectFromGUID(MANAGER_GUID).call("doRemove", playerColor) getObjectFromMemo("Mythos", "BlessCurseManager").call("doRemove", playerColor)
end end
-- adds Wendy's menu to the hovered card (allows sealing of tokens) -- adds Wendy's menu to the hovered card (allows sealing of tokens)
---@param color String Color of the player to show the broadcast to ---@param color String Color of the player to show the broadcast to
BlessCurseManagerApi.addWendysMenu = function(playerColor, hoveredObject) BlessCurseManagerApi.addWendysMenu = function(playerColor, hoveredObject)
getObjectFromGUID(MANAGER_GUID).call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject }) getObjectFromMemo("Mythos", "BlessCurseManager").call("addMenuOptions", { playerColor = playerColor, hoveredObject = hoveredObject })
end end
return BlessCurseManagerApi return BlessCurseManagerApi

View File

@ -61,7 +61,7 @@ local ENCOUNTER_DISCARD_POSITION = { x = -3.85, y = 1.5, z = 10.38}
-- global variable so it can be reset by the Clean Up Helper -- global variable so it can be reset by the Clean Up Helper
activeInvestigatorId = "00000" activeInvestigatorId = "00000"
local TRASHCAN, STAT_TRACKER, RESOURCE_COUNTER local MATCOLOR, TRASHCAN, STAT_TRACKER, RESOURCE_COUNTER
local isDrawButtonVisible = false local isDrawButtonVisible = false
-- global variable to report "Dream-Enhancing Serum" status -- global variable to report "Dream-Enhancing Serum" status
@ -79,9 +79,12 @@ end
function onLoad(save_state) function onLoad(save_state)
self.interactable = DEBUG self.interactable = DEBUG
TRASHCAN = getObjectFromGUID(TRASHCAN_GUID) -- set MATCOLOR based on memo
STAT_TRACKER = getObjectFromGUID(STAT_TRACKER_GUID) MATCOLOR = JSON.decode(self.getMemo()).matColor
RESOURCE_COUNTER = getObjectFromGUID(RESOURCE_COUNTER_GUID)
TRASHCAN = getObjectFromMemo(MATCOLOR, "Trash")
STAT_TRACKER = getObjectFromMemo(MATCOLOR, "InvestigatorSkillTracker")
RESOURCE_COUNTER = getObjectFromMemo(MATCOLOR, "ResourceCounter")
-- button creation -- button creation
for i = 1, 6 do for i = 1, 6 do
@ -209,6 +212,35 @@ function doNotReady(card)
return card.getVar("do_not_ready") or false return card.getVar("do_not_ready") or false
end end
-- rounds a number to the specified amount of decimal places
---@param num Number Initial value
---@param numDecimalPlaces Number Amount of decimal places
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end
-- gets the first object that matches the provided information
---@param matColor String Color of the playermat
---@param type String Object to look for (usually name without spaces)
function getObjectFromMemo(matColor, type)
if matColor == nil or type == nil then
return nil
end
for _, obj in ipairs(getObjects()) do
local memo = obj.getMemo()
if memo then
local decoded = JSON.decode(memo) or {}
if decoded.matColor == matColor and decoded.type == type then
return obj
end
end
end
return nil
end
--------------------------------------------------------- ---------------------------------------------------------
-- Discard buttons -- Discard buttons
--------------------------------------------------------- ---------------------------------------------------------
@ -570,32 +602,8 @@ function changeColor(clickedByColor)
-- show the option dialog for color selection to the player that triggered this -- show the option dialog for color selection to the player that triggered this
Player[clickedByColor].showOptionsDialog("Select a new color:", colorList, _, function(color) Player[clickedByColor].showOptionsDialog("Select a new color:", colorList, _, function(color)
local HAND_ZONE_GUIDS = {
"a70eee", -- White
"5fe087", -- Orange
"0285cc", -- Green
"be2f17" -- Red
}
local index
local startPos = self.getPosition()
-- get respective hand zone by position
if startPos.x < -42 then
if startPos.z > 0 then
index = 1
else
index = 2
end
else
if startPos.z > 0 then
index = 3
else
index = 4
end
end
-- update the color of the hand zone -- update the color of the hand zone
local handZone = getObjectFromGUID(HAND_ZONE_GUIDS[index]) local handZone = getObjectFromMemo(MATCOLOR, "HandZone")
handZone.setValue(color) handZone.setValue(color)
-- if the seated player clicked this, reseat him to the new color -- if the seated player clicked this, reseat him to the new color
@ -880,8 +888,8 @@ end
-- Spawns / destroys a clickable clue counter for this playmat with the correct amount of clues -- Spawns / destroys a clickable clue counter for this playmat with the correct amount of clues
---@param showCounter Boolean Whether the clickable clue counter should be present ---@param showCounter Boolean Whether the clickable clue counter should be present
function clickableClues(showCounter) function clickableClues(showCounter)
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter")
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter")
local clickerPos = CLUE_CLICKER.getPosition() local clickerPos = CLUE_CLICKER.getPosition()
local clueCount = 0 local clueCount = 0
@ -917,8 +925,8 @@ end
-- removes all clues (moving tokens to the trash and setting counters to 0) -- removes all clues (moving tokens to the trash and setting counters to 0)
function removeClues() function removeClues()
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter")
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter")
CLUE_COUNTER.call("removeAllClues") CLUE_COUNTER.call("removeAllClues")
CLUE_CLICKER.call("updateVal", 0) CLUE_CLICKER.call("updateVal", 0)
@ -930,10 +938,10 @@ function getClueCount(useClickableCounters)
local count = 0 local count = 0
if useClickableCounters then if useClickableCounters then
local CLUE_CLICKER = getObjectFromGUID(CLUE_CLICKER_GUID) local CLUE_CLICKER = getObjectFromMemo(MATCOLOR, "ClickableClueCounter")
count = tonumber(CLUE_CLICKER.getVar("val")) count = tonumber(CLUE_CLICKER.getVar("val"))
else else
local CLUE_COUNTER = getObjectFromGUID(CLUE_COUNTER_GUID) local CLUE_COUNTER = getObjectFromMemo(MATCOLOR, "ClueCounter")
count = tonumber(CLUE_COUNTER.getVar("exposedValue")) count = tonumber(CLUE_COUNTER.getVar("exposedValue"))
end end
return count return count
@ -995,11 +1003,3 @@ function updatePlayerCards(args)
local playerCardData = customDataHelper.getTable("PLAYER_CARD_DATA") local playerCardData = customDataHelper.getTable("PLAYER_CARD_DATA")
tokenManager.addPlayerCardData(playerCardData) tokenManager.addPlayerCardData(playerCardData)
end end
-- utility function for rounding
---@param num Number Initial value
---@param numDecimalPlaces Number Amount of decimal places
function round(num, numDecimalPlaces)
local mult = 10^(numDecimalPlaces or 0)
return math.floor(num * mult + 0.5) / mult
end

View File

@ -2,26 +2,26 @@ do
local PlaymatApi = { } local PlaymatApi = { }
local internal = { } local internal = { }
local MAT_IDS = { -- gets the first object that matches the provided information
White = "8b081b", ---@param matColor String Color of the playermat
Orange = "bd0ff4", ---@param type String Object to look for (usually name without spaces)
Green = "383d8b", internal.getObjectFromMemo = function(matColor, type)
Red = "0840d5" if matColor == nil or type == nil then
} return nil
end
local CLUE_COUNTER_GUIDS = { for _, obj in ipairs(getObjects()) do
White = "37be78", local memo = obj.getMemo()
Orange = "1769ed", if memo then
Green = "032300", local decoded = JSON.decode(memo) or {}
Red = "d86b7c" if decoded.matColor == matColor and decoded.type == type then
} return obj
end
end
end
local CLUE_CLICKER_GUIDS = { return nil
White = "db85d6", end
Orange = "3f22e5",
Green = "891403",
Red = "4111de"
}
-- Returns the color of the by position requested playermat as string -- Returns the color of the by position requested playermat as string
---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat ---@param startPos Table Position of the search, table get's roughly cut into 4 quarters to assign a playermat
@ -44,7 +44,7 @@ do
-- Returns the color of the player's hand that is seated next to the playermat -- Returns the color of the player's hand that is seated next to the playermat
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.getPlayerColor = function(matColor) PlaymatApi.getPlayerColor = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.getVar("playerColor") return mat.getVar("playerColor")
end end
@ -62,21 +62,21 @@ do
-- Returns the result of a cast in the specificed playermat's area -- Returns the result of a cast in the specificed playermat's area
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.searchPlaymat = function(matColor) PlaymatApi.searchPlaymat = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.call("searchAroundSelf") return mat.call("searchAroundSelf")
end end
-- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat -- Returns if there is the card "Dream-Enhancing Serum" on the requested playermat
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.isDES = function(matColor) PlaymatApi.isDES = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.getVar("isDES") return mat.getVar("isDES")
end end
-- Returns the draw deck of the requested playmat -- Returns the draw deck of the requested playmat
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.getDrawDeck = function(matColor) PlaymatApi.getDrawDeck = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
mat.call("getDrawDiscardDecks") mat.call("getDrawDiscardDecks")
return mat.getVar("drawDeck") return mat.getVar("drawDeck")
end end
@ -84,7 +84,7 @@ do
-- Returns the position of the discard pile of the requested playmat -- Returns the position of the discard pile of the requested playmat
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.getDiscardPosition = function(matColor) PlaymatApi.getDiscardPosition = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.call("returnGlobalDiscardPosition") return mat.call("returnGlobalDiscardPosition")
end end
@ -92,14 +92,14 @@ do
---@param localPos Table Local position to be transformed ---@param localPos Table Local position to be transformed
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.transformLocalPosition = function(localPos, matColor) PlaymatApi.transformLocalPosition = function(localPos, matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.positionToWorld(localPos) return mat.positionToWorld(localPos)
end end
-- Returns the rotation of the requested playmat -- Returns the rotation of the requested playmat
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.returnRotation = function(matColor) PlaymatApi.returnRotation = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.getRotation() return mat.getRotation()
end end
@ -107,14 +107,14 @@ do
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
---@param playerColor String Color of the calling player (for messages) ---@param playerColor String Color of the calling player (for messages)
PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.call("doUpkeepFromHotkey", playerColor) return mat.call("doUpkeepFromHotkey", playerColor)
end end
-- Returns the active investigator id -- Returns the active investigator id
---@param matColor String Color of the playermat ---@param matColor String Color of the playermat
PlaymatApi.returnInvestigatorId = function(matColor) PlaymatApi.returnInvestigatorId = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.getVar("activeInvestigatorId") return mat.getVar("activeInvestigatorId")
end end
@ -180,7 +180,7 @@ do
-- Returns the resource counter amount for the requested playermat -- Returns the resource counter amount for the requested playermat
PlaymatApi.getResourceCount = function(matColor) PlaymatApi.getResourceCount = function(matColor)
local mat = getObjectFromGUID(MAT_IDS[matColor]) local mat = internal.getObjectFromMemo(matColor, "Playermat")
return mat.call("getResourceCount") return mat.call("getResourceCount")
end end
@ -197,8 +197,8 @@ do
end end
end end
PlaymatApi.updateClueClicker = function(playerColor, val) PlaymatApi.updateClueClicker = function(matColor, val)
return getObjectFromGUID(CLUE_CLICKER_GUIDS[playerColor]).call("updateVal", val) return internal.getObjectFromMemo(matColor, "ClickableClueCounter").call("updateVal", val)
end end
-- Convenience function to look up a mat's object by color, or get all mats. -- Convenience function to look up a mat's object by color, or get all mats.
@ -207,16 +207,16 @@ do
---@return: Array of playermat objects. If a single mat is requested, will return a single-element ---@return: Array of playermat objects. If a single mat is requested, will return a single-element
-- array to simplify processing by consumers. -- array to simplify processing by consumers.
internal.getMatForColor = function(matColor) internal.getMatForColor = function(matColor)
local targetMatGuid = MAT_IDS[matColor] local targetMat = internal.getObjectFromMemo(matColor, "Playermat")
if targetMatGuid != nil then if targetMat != nil then
return { getObjectFromGUID(targetMatGuid) } return { targetMatGuid }
end end
if matColor == "All" then if matColor == "All" then
return { return {
getObjectFromGUID(MAT_IDS.White), internal.getObjectFromMemo("White", "Playermat"),
getObjectFromGUID(MAT_IDS.Orange), internal.getObjectFromMemo("Orange", "Playermat"),
getObjectFromGUID(MAT_IDS.Green), internal.getObjectFromMemo("Green", "Playermat"),
getObjectFromGUID(MAT_IDS.Red), internal.getObjectFromMemo("Red", "Playermat"),
} }
end end
end end