swapped references to GUID handler to GUIDs

This commit is contained in:
Chr1Z93 2023-10-02 21:16:36 +02:00
parent 8de5fc6b56
commit bd1bbb92de
27 changed files with 74 additions and 77 deletions

View File

@ -20,7 +20,7 @@
"MusicPlayer_path": "MusicPlayer.json",
"Note": "",
"ObjectStates_order": [
"GUIDReferenceHandler.da23e4",
"GUIDReferenceHandler.123456",
"HandTrigger.5fe087",
"HandTrigger.be2f17",
"HandTrigger.0285cc",

View File

@ -12,10 +12,6 @@
"displayed": "LinkedPhaseTracker",
"normalized": "linkedphasetracker"
},
{
"displayed": "chaosBag",
"normalized": "chaosBag"
},
{
"displayed": "displacement_excluded",
"normalized": "displacement_excluded"

View File

@ -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": ""
}
}

View File

@ -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",

View File

@ -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"

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -4,7 +4,7 @@ local options = {
Playarea = true,
Playermats = true
}
local guidHandler = getObjectsWithTag("GUIDs")[1]
local guidHandler = getObjectFromGUID("123456")
val = 0

View File

@ -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"

View File

@ -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)

View File

@ -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()

View File

@ -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 },

View File

@ -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

View File

@ -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

View File

@ -2,7 +2,7 @@
-- general setup
---------------------------------------------------------
local guidHandler = getObjectsWithTag("GUIDs")[1]
local guidHandler = getObjectFromGUID("123456")
-- Location connection directional options
local BIDIRECTIONAL = 0

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -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

View File

@ -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')

View File

@ -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

View File

@ -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

View File

@ -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"

View File

@ -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

View File

@ -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

View File

@ -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