From bd1bbb92de701286ef2bcc36332ec440c4f5a28b Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Mon, 2 Oct 2023 21:16:36 +0200 Subject: [PATCH] swapped references to GUID handler to GUIDs --- config.json | 2 +- modsettings/ComponentTags.json | 4 -- ....json => GUIDReferenceHandler.123456.json} | 7 +- .../CampaignImporterExporter.ttslua | 2 +- src/accessories/CleanUpHelper.ttslua | 2 +- src/accessories/TokenArrangerApi.ttslua | 2 +- src/arkhamdb/DeckImporterApi.ttslua | 13 ++-- src/chaosbag/BlessCurseManagerApi.ttslua | 2 +- src/core/DoomCounter.ttslua | 2 +- src/core/DoomInPlayCounter.ttslua | 2 +- src/core/GameKeyHandler.ttslua | 2 +- src/core/Global.ttslua | 2 +- src/core/MythosArea.ttslua | 2 +- src/core/MythosAreaApi.ttslua | 2 +- src/core/NavigationOverlayApi.ttslua | 2 +- src/core/PlayArea.ttslua | 2 +- src/core/PlayAreaApi.ttslua | 3 +- src/core/SoundCubeApi.ttslua | 2 +- src/core/VictoryDisplay.ttslua | 2 +- src/core/VictoryDisplayApi.ttslua | 2 +- src/core/token/TokenManager.ttslua | 4 +- src/core/token/TokenSpawnTrackerApi.ttslua | 2 +- src/core/tour/TourManager.ttslua | 5 +- src/core/tour/TourScript.ttslua | 10 +-- src/playercards/AllCardsBagApi.ttslua | 2 +- src/playermat/Playmat.ttslua | 2 +- src/playermat/PlaymatApi.ttslua | 67 +++++++++---------- 27 files changed, 74 insertions(+), 77 deletions(-) rename objects/{GUIDReferenceHandler.da23e4.json => GUIDReferenceHandler.123456.json} (94%) diff --git a/config.json b/config.json index 3419252a..61fdf6ab 100644 --- a/config.json +++ b/config.json @@ -20,7 +20,7 @@ "MusicPlayer_path": "MusicPlayer.json", "Note": "", "ObjectStates_order": [ - "GUIDReferenceHandler.da23e4", + "GUIDReferenceHandler.123456", "HandTrigger.5fe087", "HandTrigger.be2f17", "HandTrigger.0285cc", diff --git a/modsettings/ComponentTags.json b/modsettings/ComponentTags.json index ad3908c8..3e61c8d2 100644 --- a/modsettings/ComponentTags.json +++ b/modsettings/ComponentTags.json @@ -12,10 +12,6 @@ "displayed": "LinkedPhaseTracker", "normalized": "linkedphasetracker" }, - { - "displayed": "chaosBag", - "normalized": "chaosBag" - }, { "displayed": "displacement_excluded", "normalized": "displacement_excluded" diff --git a/objects/GUIDReferenceHandler.da23e4.json b/objects/GUIDReferenceHandler.123456.json similarity index 94% rename from objects/GUIDReferenceHandler.da23e4.json rename to objects/GUIDReferenceHandler.123456.json index fd8605f6..096e5e49 100644 --- a/objects/GUIDReferenceHandler.da23e4.json +++ b/objects/GUIDReferenceHandler.123456.json @@ -13,7 +13,7 @@ "Description": "This object handles GUID references to objects.", "DragSelectable": true, "GMNotes": "", - "GUID": "da23e4", + "GUID": "123456", "Grid": true, "GridProjection": false, "Hands": false, @@ -28,9 +28,6 @@ "Nickname": "GUID Reference Handler", "Snap": true, "Sticky": true, - "Tags": [ - "GUIDs" - ], "Tooltip": true, "Transform": { "posX": 78, @@ -45,4 +42,4 @@ }, "Value": 0, "XmlUI": "" -} +} \ No newline at end of file diff --git a/src/accessories/CampaignImporterExporter.ttslua b/src/accessories/CampaignImporterExporter.ttslua index 7084f679..8b5e6075 100644 --- a/src/accessories/CampaignImporterExporter.ttslua +++ b/src/accessories/CampaignImporterExporter.ttslua @@ -5,7 +5,7 @@ local optionPanelApi = require("core/OptionPanelApi") local playAreaApi = require("core/PlayAreaApi") local playmatApi = require("playermat/PlaymatApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") local campaignTokenData = { Name = "Custom_Model", diff --git a/src/accessories/CleanUpHelper.ttslua b/src/accessories/CleanUpHelper.ttslua index ac4d4fc5..c64d2dab 100644 --- a/src/accessories/CleanUpHelper.ttslua +++ b/src/accessories/CleanUpHelper.ttslua @@ -10,7 +10,7 @@ local playmatApi = require("playermat/PlaymatApi") local soundCubeApi = require("core/SoundCubeApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- objects with this tag will be ignored local IGNORE_TAG = "CleanUpHelper_ignore" diff --git a/src/accessories/TokenArrangerApi.ttslua b/src/accessories/TokenArrangerApi.ttslua index 7f2dee07..846c0648 100644 --- a/src/accessories/TokenArrangerApi.ttslua +++ b/src/accessories/TokenArrangerApi.ttslua @@ -1,11 +1,11 @@ do local TokenArrangerApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] -- local function to call the token arranger, if it is on the table ---@param functionName String Name of the function to cal ---@param argument Variant Parameter to pass local function callIfExistent(functionName, argument) + local guidHandler = getObjectFromGUID("123456") local tokenArranger = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenArranger" }) if tokenArranger ~= nil then tokenArranger.call(functionName, argument) diff --git a/src/arkhamdb/DeckImporterApi.ttslua b/src/arkhamdb/DeckImporterApi.ttslua index 0ada1a1d..221a5f5d 100644 --- a/src/arkhamdb/DeckImporterApi.ttslua +++ b/src/arkhamdb/DeckImporterApi.ttslua @@ -1,6 +1,11 @@ do local DeckImporterApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] + + + local function getDeckImporter() + local guidHandler = getObjectFromGUID("123456") + return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) + end -- Returns a table with the full state of the UI, including options and deck IDs. -- This can be used to persist via onSave(), or provide values for a load operation @@ -14,8 +19,7 @@ do -- investigators: True if investigator cards should be spawned DeckImporterApi.getUiState = function() local passthroughTable = {} - local DeckImporter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) - for k,v in pairs(DeckImporter.call("getUiState")) do + for k,v in pairs(getDeckImporter().call("getUiState")) do passthroughTable[k] = v end return passthroughTable @@ -32,8 +36,7 @@ do -- loadNewest: True if the most upgraded version of the deck should be loaded -- investigators: True if investigator cards should be spawned DeckImporterApi.setUiState = function(uiStateTable) - local DeckImporter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" }) - return DeckImporter.call("setUiState", uiStateTable) + return getDeckImporter().call("setUiState", uiStateTable) end return DeckImporterApi diff --git a/src/chaosbag/BlessCurseManagerApi.ttslua b/src/chaosbag/BlessCurseManagerApi.ttslua index f4861587..d0cd5b9c 100644 --- a/src/chaosbag/BlessCurseManagerApi.ttslua +++ b/src/chaosbag/BlessCurseManagerApi.ttslua @@ -1,8 +1,8 @@ do local BlessCurseManagerApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getManager() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "BlessCurseManager" }) end diff --git a/src/core/DoomCounter.ttslua b/src/core/DoomCounter.ttslua index c70fcead..f39ad72d 100644 --- a/src/core/DoomCounter.ttslua +++ b/src/core/DoomCounter.ttslua @@ -4,7 +4,7 @@ local options = { Playarea = true, Playermats = true } -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") val = 0 diff --git a/src/core/DoomInPlayCounter.ttslua b/src/core/DoomInPlayCounter.ttslua index 4688efd5..cb851055 100644 --- a/src/core/DoomInPlayCounter.ttslua +++ b/src/core/DoomInPlayCounter.ttslua @@ -1,6 +1,6 @@ local playmatApi = require("playermat/PlaymatApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") local ZONE, TRASH, loopID local doomURL = "https://i.imgur.com/EoL7yaZ.png" diff --git a/src/core/GameKeyHandler.ttslua b/src/core/GameKeyHandler.ttslua index aaee28aa..b1427e37 100644 --- a/src/core/GameKeyHandler.ttslua +++ b/src/core/GameKeyHandler.ttslua @@ -3,7 +3,7 @@ local optionPanelApi = require("core/OptionPanelApi") local playmatApi = require("playermat/PlaymatApi") local victoryDisplayApi = require("core/VictoryDisplayApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") function onLoad() addHotkey("Add Doom to Agenda", addDoomToAgenda) diff --git a/src/core/Global.ttslua b/src/core/Global.ttslua index 136338ad..7cc27b65 100644 --- a/src/core/Global.ttslua +++ b/src/core/Global.ttslua @@ -127,7 +127,7 @@ function onLoad(savedData) if obj ~= nil then obj.interactable = false end end - guidHandler = getObjectsWithTag("GUIDs")[1] + guidHandler = getObjectFromGUID("123456") DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) resetChaosTokenStatTracker() getModVersion() diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index c0f63408..12100390 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -3,7 +3,7 @@ local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenChecker = require("core/token/TokenChecker") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") local ENCOUNTER_DECK_AREA = { upperLeft = { x = 0.9, z = 0.42 }, diff --git a/src/core/MythosAreaApi.ttslua b/src/core/MythosAreaApi.ttslua index 702c538d..89f7987b 100644 --- a/src/core/MythosAreaApi.ttslua +++ b/src/core/MythosAreaApi.ttslua @@ -1,8 +1,8 @@ do local MythosAreaApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getMythosArea() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "MythosArea" }) end diff --git a/src/core/NavigationOverlayApi.ttslua b/src/core/NavigationOverlayApi.ttslua index 995fdbaf..e1249730 100644 --- a/src/core/NavigationOverlayApi.ttslua +++ b/src/core/NavigationOverlayApi.ttslua @@ -1,8 +1,8 @@ do local NavigationOverlayApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getNOHandler() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "NavigationOverlayHandler" }) end diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 4a360321..cfdf7932 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -2,7 +2,7 @@ -- general setup --------------------------------------------------------- -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- Location connection directional options local BIDIRECTIONAL = 0 diff --git a/src/core/PlayAreaApi.ttslua b/src/core/PlayAreaApi.ttslua index 54291f5f..a66bc39e 100644 --- a/src/core/PlayAreaApi.ttslua +++ b/src/core/PlayAreaApi.ttslua @@ -1,12 +1,13 @@ do local PlayAreaApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getPlayArea() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayArea" }) end local function getInvestigatorCounter() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "InvestigatorCounter" }) end diff --git a/src/core/SoundCubeApi.ttslua b/src/core/SoundCubeApi.ttslua index 0339f519..36db9085 100644 --- a/src/core/SoundCubeApi.ttslua +++ b/src/core/SoundCubeApi.ttslua @@ -1,6 +1,5 @@ do local SoundCubeApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] -- this table links the name of a trigger effect to its index local soundIndices = { @@ -10,6 +9,7 @@ do } local function playTriggerEffect(index) + local guidHandler = getObjectFromGUID("123456") local SoundCube = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "SoundCube" }) SoundCube.AssetBundle.playTriggerEffect(index) end diff --git a/src/core/VictoryDisplay.ttslua b/src/core/VictoryDisplay.ttslua index 36680eff..3226cbbc 100644 --- a/src/core/VictoryDisplay.ttslua +++ b/src/core/VictoryDisplay.ttslua @@ -10,7 +10,7 @@ local countedVP = {} local highlightMissing = false local highlightCounted = false -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- button creation when loading the game function onLoad() diff --git a/src/core/VictoryDisplayApi.ttslua b/src/core/VictoryDisplayApi.ttslua index dc14fe0a..e15d8813 100644 --- a/src/core/VictoryDisplayApi.ttslua +++ b/src/core/VictoryDisplayApi.ttslua @@ -1,8 +1,8 @@ do local VictoryDisplayApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getVictoryDisplay() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "VictoryDisplay" }) end diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 91504bd6..67251e2a 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -3,8 +3,6 @@ do local playAreaApi = require("core/PlayAreaApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") - local guidHandler = getObjectsWithTag("GUIDs")[1] - local PLAYER_CARD_TOKEN_OFFSETS = { [1] = { Vector(0, 3, -0.2) @@ -337,6 +335,7 @@ do return end tokenTemplates = { } + local guidHandler = getObjectFromGUID("123456") local tokenSource = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSource" }) for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do local tokenName = tokenTemplate.Memo @@ -349,6 +348,7 @@ do if playerCardData ~= nil then return end + local guidHandler = getObjectFromGUID("123456") local dataHelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) playerCardData = dataHelper.getTable('PLAYER_CARD_DATA') locationData = dataHelper.getTable('LOCATIONS_DATA') diff --git a/src/core/token/TokenSpawnTrackerApi.ttslua b/src/core/token/TokenSpawnTrackerApi.ttslua index 23cf7b8f..e82f3057 100644 --- a/src/core/token/TokenSpawnTrackerApi.ttslua +++ b/src/core/token/TokenSpawnTrackerApi.ttslua @@ -1,8 +1,8 @@ do local TokenSpawnTracker = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getSpawnTracker() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSpawnTracker" }) end diff --git a/src/core/tour/TourManager.ttslua b/src/core/tour/TourManager.ttslua index 4f67e09a..2b0ec255 100644 --- a/src/core/tour/TourManager.ttslua +++ b/src/core/tour/TourManager.ttslua @@ -123,8 +123,9 @@ do delay = delay + 0.5 end local lookPos - if TOUR_SCRIPT[cardIndex].objMemoData ~= nil then - local lookAtObj = Global.call("getObjectFromMemo", TOUR_SCRIPT[cardIndex].objMemoData) + if TOUR_SCRIPT[cardIndex].objReferenceData ~= nil then + local guidHandler = getObjectFromGUID("123456") + local lookAtObj = guidHandler.call("getObjectByOwnerAndType", TOUR_SCRIPT[cardIndex].objReferenceData) lookPos = lookAtObj.getPosition() lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0 -- Since camera isn't directly above the hook, changing the Y affects the visual position of diff --git a/src/core/tour/TourScript.ttslua b/src/core/tour/TourScript.ttslua index 203e7d05..6caf67e7 100644 --- a/src/core/tour/TourScript.ttslua +++ b/src/core/tour/TourScript.ttslua @@ -15,7 +15,7 @@ TOUR_SCRIPT = { { narrator = "Daisy", text = "If you're new to the game, the library here has everything you'll need. A little research can go a long way, and looking into old newspapers for the weird and unusual can yield some surprisingly helpful information.\n\nI put a few right there that might prove enlightening.", - objMemoData = { matColor = "Mythos", type = "RulesReference" }, + objReferenceData = { owner = "Mythos", type = "RulesReference" }, distanceFromObj = 20, position = "west", speakerSide = "right" @@ -23,7 +23,7 @@ TOUR_SCRIPT = { { narrator = "Mandy", text = "To survive what's coming you'll need a deck. If it's safely hidden away on ArkhamDB you can load it here, and even find the newest version after an upgrade without changing the ID.\n\nNo need to publish all your decks, use 'Private' and you can see it. Just make sure to select 'Make your decks public' in ArkhamDB.", - objMemoData = { matColor = "Mythos", type = "DeckImporter" }, + objReferenceData = { owner = "Mythos", type = "DeckImporter" }, distanceFromObj = -5, position = "northwest", skipCentering = true, @@ -31,7 +31,7 @@ TOUR_SCRIPT = { { narrator = "Daniela", text = "I prefer the hands-on approach to building things, if you do too you can build a deck yourself.\n\nAll the cards you could ever need are here, laid out like a disassembled engine. Place the cards on the table, copy them for your deck, and you'll be ready for anything.", - objMemoData = { matColor = "Mythos", type = "PlayerCardPanel" }, + objReferenceData = { owner = "Mythos", type = "PlayerCardPanel" }, distanceFromObj = -7, position = "south", speakerSide = "right" @@ -39,7 +39,7 @@ TOUR_SCRIPT = { { narrator = "Finn", text = "Ready to face the unknown? We've smuggled shocking revelations and devious enemies from all over the world. Download the campaign you want to play, then Place it on the table to see the scenarios.\n\nJust remember - if it turns out to be too much for you, I was never here.", - objMemoData = { matColor = "Mythos", type = "CampaignThePathToCarcosa" }, + objReferenceData = { owner = "Mythos", type = "CampaignThePathToCarcosa" }, distanceFromObj = 20, position = "northwest", }, @@ -77,7 +77,7 @@ TOUR_SCRIPT = { { narrator = "Preston", text = "I can afford to buy what I need, but for those less well-off we've provided an endless pool of tokens to track your game. Simply drag one out of the pools here.\n\nResources are my favorite of course, but damage and horror are as inevitable as taxes. I leave those to my bookkeeper though. Those tokens can work like counters, use the number keys to change the value.", - objMemoData = { matColor = "Mythos", type = "ResourceTokenBag" }, + objReferenceData = { owner = "Mythos", type = "ResourceTokenBag" }, position = "north", skipCentering = true, speakerSide = "right" diff --git a/src/playercards/AllCardsBagApi.ttslua b/src/playercards/AllCardsBagApi.ttslua index 8b0387f5..6178c6f1 100644 --- a/src/playercards/AllCardsBagApi.ttslua +++ b/src/playercards/AllCardsBagApi.ttslua @@ -1,8 +1,8 @@ do local AllCardsBagApi = {} - local guidHandler = getObjectsWithTag("GUIDs")[1] local function getAllCardsBag() + local guidHandler = getObjectFromGUID("123456") return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "AllCardsBag" }) end diff --git a/src/playermat/Playmat.ttslua b/src/playermat/Playmat.ttslua index 586fa356..af2e2a4c 100644 --- a/src/playermat/Playmat.ttslua +++ b/src/playermat/Playmat.ttslua @@ -4,7 +4,7 @@ local navigationOverlayApi = require("core/NavigationOverlayApi") local tokenChecker = require("core/token/TokenChecker") local tokenManager = require("core/token/TokenManager") -local guidHandler = getObjectsWithTag("GUIDs")[1] +local guidHandler = getObjectFromGUID("123456") -- set true to enable debug logging and show Physics.cast() local DEBUG = false diff --git a/src/playermat/PlaymatApi.ttslua b/src/playermat/PlaymatApi.ttslua index 30e4759f..6fb11f28 100644 --- a/src/playermat/PlaymatApi.ttslua +++ b/src/playermat/PlaymatApi.ttslua @@ -1,12 +1,23 @@ do local PlaymatApi = {} - local internal = {} + + -- Convenience function to look up a mat's object by color, or get all mats. + ---@param matColor String Color of the playmat - White, Orange, Green, Red or All + ---@return array Table Single-element if only single playmat is requested + local function getMatForColor(matColor) + local guidHandler = getObjectFromGUID("123456") + if matColor == "All" then + return guidHandler.call("getObjectsByType", "Playermat") + else + return { matColor = guidHandler.call("getObjectByOwnerAndType", { owner = matColor, type = "Playermat" }) } + end + end -- Returns the color of the closest playmat ---@param startPos Table Starting position to get the closest mat from PlaymatApi.getMatColorByPosition = function(startPos) local result, smallestDistance - for matColor, mat in pairs(internal.getMatForColor("All")) do + for matColor, mat in pairs(getMatForColor("All")) do local distance = Vector.between(startPos, mat.getPosition()):magnitude() if smallestDistance == nil or distance < smallestDistance then smallestDistance = distance @@ -19,7 +30,7 @@ do -- Returns the color of the player's hand that is seated next to the playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getPlayerColor = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("playerColor") end end @@ -27,7 +38,7 @@ do -- Returns the color of the playmat that owns the playercolor's hand ---@param handColor String Color of the playmat PlaymatApi.getMatColor = function(handColor) - for matColor, mat in pairs(internal.getMatForColor("All")) do + for matColor, mat in pairs(getMatForColor("All")) do local playerColor = mat.getVar("playerColor") if playerColor == handColor then return matColor @@ -38,7 +49,7 @@ do -- Returns if there is the card "Dream-Enhancing Serum" on the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.isDES = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("isDES") end end @@ -46,7 +57,7 @@ do -- Returns the draw deck of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDrawDeck = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("getDrawDiscardDecks") return mat.getVar("drawDeck") end @@ -55,7 +66,7 @@ do -- Returns the position of the discard pile of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.getDiscardPosition = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.call("returnGlobalDiscardPosition") end end @@ -64,7 +75,7 @@ do ---@param localPos Table Local position to be transformed ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.transformLocalPosition = function(localPos, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.positionToWorld(localPos) end end @@ -72,7 +83,7 @@ do -- Returns the rotation of the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnRotation = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getRotation() end end @@ -81,7 +92,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param playerColor String Color of the calling player (for messages) PlaymatApi.doUpkeepFromHotkey = function(matColor, playerColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("doUpkeepFromHotkey", playerColor) end end @@ -89,7 +100,7 @@ do -- Returns the active investigator id ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") PlaymatApi.returnInvestigatorId = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.getVar("activeInvestigatorId") end end @@ -101,7 +112,7 @@ do ---@param matchCardTypes Boolean Whether snap points should only snap for the matching card types ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.setLimitSnapsByType = function(matchCardTypes, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("setLimitSnapsByType", matchCardTypes) end end @@ -110,7 +121,7 @@ do ---@param isDrawButtonVisible Boolean Whether the draw 1 button should be visible or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.showDrawButton = function(isDrawButtonVisible, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("showDrawButton", isDrawButtonVisible) end end @@ -119,7 +130,7 @@ do ---@param showCounter Boolean Whether the clickable counter should be present or not ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.clickableClues = function(showCounter, matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("clickableClues", showCounter) end end @@ -127,7 +138,7 @@ do -- Removes all clues (to the trash for tokens and counters set to 0) for the requested playmat ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.removeClues = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("removeClues") end end @@ -136,7 +147,7 @@ do ---@param useClickableCounters Boolean Controls which type of counter is getting checked PlaymatApi.getClueCount = function(useClickableCounters, matColor) local count = 0 - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do count = count + mat.call("getClueCount", useClickableCounters) end return count @@ -148,7 +159,7 @@ do ---@param newValue Number Value to set the counter to ---@param modifier Number If newValue is not provided, the existing value will be adjusted by this modifier PlaymatApi.updateCounter = function(matColor, type, newValue, modifier) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("updateCounter", { type = type, newValue = newValue, modifier = modifier }) end end @@ -157,7 +168,7 @@ do ---@param matColor String Color of the playmat - White, Orange, Green or Red (does not support "All") ---@param type String Counter to target PlaymatApi.getCounterValue = function(matColor, type) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do return mat.call("getCounterValue", type) end end @@ -165,7 +176,7 @@ do -- resets the specified skill tracker to "1, 1, 1, 1" ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.resetSkillTracker = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("resetSkillTracker") end end @@ -175,7 +186,7 @@ do ---@param filter Function Optional filter function (return true for desired objects) PlaymatApi.searchAroundPlaymat = function(matColor, filter) local objList = {} - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do for _, obj in ipairs(mat.call("searchAroundSelf", filter)) do table.insert(objList, obj) end @@ -186,29 +197,17 @@ do -- Discard a non-hidden card from the corresponding player's hand ---@param matColor String Color of the playmat - White, Orange, Green, Red or All PlaymatApi.doDiscardOne = function(matColor) - for _, mat in pairs(internal.getMatForColor(matColor)) do + for _, mat in pairs(getMatForColor(matColor)) do mat.call("doDiscardOne") end end -- Triggers the metadata sync for all playmats PlaymatApi.syncAllCustomizableCards = function() - for _, mat in pairs(internal.getMatForColor("All")) do + for _, mat in pairs(getMatForColor("All")) do mat.call("syncAllCustomizableCards") end end - -- Convenience function to look up a mat's object by color, or get all mats. - ---@param matColor String Color of the playmat - White, Orange, Green, Red or All - ---@return array Table Single-element if only single playmat is requested - internal.getMatForColor = function(matColor) - local guidHandler = getObjectsWithTag("GUIDs")[1] - if matColor == "All" then - return guidHandler.call("getObjectsByType", "Playermat") - else - return { matColor = guidHandler.call("getObjectByOwnerAndType", { owner = matColor, type = "Playermat" }) } - end - end - return PlaymatApi end