resolving review comments

This commit is contained in:
Chr1Z93 2023-10-18 20:55:38 +02:00
parent 838aa5234b
commit 4159dfc43d
27 changed files with 112 additions and 118 deletions

View File

@ -1,12 +1,11 @@
local blessCurseApi = require("chaosbag/BlessCurseManagerApi") local blessCurseApi = require("chaosbag/BlessCurseManagerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local deckImporterApi = require("arkhamdb/DeckImporterApi") local deckImporterApi = require("arkhamdb/DeckImporterApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local optionPanelApi = require("core/OptionPanelApi") local optionPanelApi = require("core/OptionPanelApi")
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local playmatApi = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
local guidHandler = getObjectFromGUID("123456")
local campaignTokenData = { local campaignTokenData = {
Name = "Custom_Model", Name = "Custom_Model",
Transform = { Transform = {
@ -165,7 +164,7 @@ function createCampaignFromToken(importData)
Wait.time(function() optionPanelApi.loadSettings(importData["options"]) end, 0.5) Wait.time(function() optionPanelApi.loadSettings(importData["options"]) end, 0.5)
-- destroy Tour Starter token -- destroy Tour Starter token
local tourStarter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TourStarter" }) local tourStarter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TourStarter")
tourStarter.destruct() tourStarter.destruct()
-- restore PlayArea image -- restore PlayArea image

View File

@ -5,13 +5,12 @@
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local playmatApi = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
local soundCubeApi = require("core/SoundCubeApi") local soundCubeApi = require("core/SoundCubeApi")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
local guidHandler = getObjectFromGUID("123456")
-- objects with this tag will be ignored -- objects with this tag will be ignored
local IGNORE_TAG = "CleanUpHelper_ignore" local IGNORE_TAG = "CleanUpHelper_ignore"
@ -146,7 +145,7 @@ end
-- reset doom on agenda -- reset doom on agenda
function resetDoomCounter() function resetDoomCounter()
local doomCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomCounter" }) local doomCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomCounter")
if doomCounter ~= nil then if doomCounter ~= nil then
doomCounter.call("updateVal") doomCounter.call("updateVal")
else else
@ -231,7 +230,7 @@ end
function discardHands() function discardHands()
if not options["tidyPlayermats"] then return end if not options["tidyPlayermats"] then return end
for i = 1, 4 do for i = 1, 4 do
local trash = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Trash" }) local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash")
if trash == nil then return end if trash == nil then return end
local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects() local hand = Player[playmatApi.getPlayerColor(COLORS[i])].getHandObjects()
for j = #hand, 1, -1 do for j = #hand, 1, -1 do
@ -242,8 +241,8 @@ end
-- clean up for play area -- clean up for play area
function tidyPlayareaCoroutine() function tidyPlayareaCoroutine()
local trash = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
local playAreaZone = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) local playAreaZone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
if playAreaZone == nil then if playAreaZone == nil then
printToAll("Scripting zone for main play area could not be found!", "Red") printToAll("Scripting zone for main play area could not be found!", "Red")
@ -273,7 +272,7 @@ function tidyPlayerMatCoroutine()
for k = 1, 30 do coroutine.yield(0) end for k = 1, 30 do coroutine.yield(0) end
-- get respective trash -- get respective trash
local trash = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Trash" }) local trash = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Trash")
if trash == nil then if trash == nil then
printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red") printToAll("Trashcan for " .. COLORS[i] .. " playmat could not be found!", "Red")
return 1 return 1
@ -303,7 +302,7 @@ function tidyPlayerMatCoroutine()
-- reset "activeInvestigatorId" -- reset "activeInvestigatorId"
if i < 5 then if i < 5 then
local playermat = guidHandler.call("getObjectByOwnerAndType", { owner = COLORS[i], type = "Playermat" }) local playermat = guidReferenceApi.getObjectByOwnerAndType(COLORS[i], "Playermat")
if playermat then if playermat then
playermat.setVar("activeInvestigatorId", "00000") playermat.setVar("activeInvestigatorId", "00000")
end end
@ -311,7 +310,7 @@ function tidyPlayerMatCoroutine()
end end
end end
local datahelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) local datahelper = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper")
if datahelper then if datahelper then
datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {}) datahelper.setTable("SPAWNED_PLAYER_CARD_GUIDS", {})
end end

View File

@ -1,12 +1,12 @@
do do
local TokenArrangerApi = {} local TokenArrangerApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
-- 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 guidHandler = getObjectFromGUID("123456") local tokenArranger = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenArranger")
local tokenArranger = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenArranger" })
if tokenArranger ~= nil then if tokenArranger ~= nil then
tokenArranger.call(functionName, argument) tokenArranger.call(functionName, argument)
end end

View File

@ -1,10 +1,9 @@
do do
local DeckImporterApi = {} local DeckImporterApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getDeckImporter() local function getDeckImporter()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "DeckImporter")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DeckImporter" })
end end
-- Returns a table with the full state of the UI, including options and deck IDs. -- Returns a table with the full state of the UI, including options and deck IDs.

View File

@ -1,9 +1,9 @@
do do
local BlessCurseManagerApi = {} local BlessCurseManagerApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getManager() local function getManager()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "BlessCurseManager")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "BlessCurseManager" })
end end
-- removes all taken tokens and resets the counts -- removes all taken tokens and resets the counts

View File

@ -1,10 +1,11 @@
local guidReferenceApi = require("core/GUIDReferenceApi")
local optionsVisible = false local optionsVisible = false
local options = { local options = {
Agenda = true, Agenda = true,
Playarea = true, Playarea = true,
Playermats = true Playermats = true
} }
local guidHandler = getObjectFromGUID("123456")
val = 0 val = 0
@ -65,9 +66,9 @@ function startReset()
if options.Agenda then if options.Agenda then
updateVal(0) updateVal(0)
end end
local DoomInPlayCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomInPlayCounter" }) local doomInPlayCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomInPlayCounter")
if DoomInPlayCounter then if doomInPlayCounter then
DoomInPlayCounter.call("removeDoom", options) doomInPlayCounter.call("removeDoom", options)
end end
end end

View File

@ -1,7 +1,6 @@
local guidReferenceApi = require("core/GUIDReferenceApi")
local playmatApi = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
local guidHandler = getObjectFromGUID("123456")
local ZONE, TRASH, loopID local ZONE, TRASH, loopID
local doomURL = "https://i.imgur.com/EoL7yaZ.png" local doomURL = "https://i.imgur.com/EoL7yaZ.png"
local IGNORE_TAG = "DoomCounter_ignore" local IGNORE_TAG = "DoomCounter_ignore"
@ -31,8 +30,8 @@ function onLoad()
color = { 0, 0, 0, 0 } color = { 0, 0, 0, 0 }
}) })
TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
ZONE = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" }) ZONE = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
loopID = Wait.time(countDoom, 2, -1) loopID = Wait.time(countDoom, 2, -1)
end end

View File

@ -0,0 +1,28 @@
do
local GUIDReferenceApi = {}
local function getGuidHandler()
return getObjectFromGUID("123456")
end
-- returns all matching objects as a table with references
---@param owner String Parent object for this search
---@param type String Type of object to search for
GUIDReferenceApi.getObjectByOwnerAndType = function(owner, type)
return getGuidHandler().call("getObjectByOwnerAndType", { owner = owner, type = type })
end
-- returns all matching objects as a table with references
---@param type String Type of object to search for
GUIDReferenceApi.getObjectsByType = function(type)
return getGuidHandler().call("getObjectsByType", type)
end
-- returns all matching objects as a table with references
---@param owner String Parent object for this search
GUIDReferenceApi.getObjectsByOwner = function(owner)
return getGuidHandler().call("getObjectsByOwner", owner)
end
return GUIDReferenceApi
end

View File

@ -71,9 +71,9 @@ local GuidReferences = {
} }
} }
function getObjectByOwnerAndType(param) function getObjectByOwnerAndType(params)
local owner = param.owner local owner = params.owner or "Mythos"
local type = param.type local type = params.type
return getObjectFromGUID(GuidReferences[owner][type]) return getObjectFromGUID(GuidReferences[owner][type])
end end

View File

@ -1,10 +1,9 @@
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local optionPanelApi = require("core/OptionPanelApi") local optionPanelApi = require("core/OptionPanelApi")
local playmatApi = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
local victoryDisplayApi = require("core/VictoryDisplayApi") local victoryDisplayApi = require("core/VictoryDisplayApi")
local guidHandler = getObjectFromGUID("123456")
function onLoad() function onLoad()
addHotkey("Add Doom to Agenda", addDoomToAgenda) addHotkey("Add Doom to Agenda", addDoomToAgenda)
addHotkey("Bless/Curse Status", showBlessCurseStatus) addHotkey("Bless/Curse Status", showBlessCurseStatus)
@ -43,7 +42,7 @@ end
-- adds 1 doom to the agenda -- adds 1 doom to the agenda
function addDoomToAgenda() function addDoomToAgenda()
local doomCounter = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DoomCounter" }) local doomCounter = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DoomCounter")
doomCounter.call("addVal", 1) doomCounter.call("addVal", 1)
end end

View File

@ -1,4 +1,5 @@
local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi") local blessCurseManagerApi = require("chaosbag/BlessCurseManagerApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local mythosAreaApi = require("core/MythosAreaApi") local mythosAreaApi = require("core/MythosAreaApi")
local navigationOverlayApi = require("core/NavigationOverlayApi") local navigationOverlayApi = require("core/NavigationOverlayApi")
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
@ -135,8 +136,7 @@ function onLoad(savedData)
if obj ~= nil then obj.interactable = false end if obj ~= nil then obj.interactable = false end
end end
guidHandler = getObjectFromGUID("123456") DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper")
DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" })
resetChaosTokenStatTracker() resetChaosTokenStatTracker()
getModVersion() getModVersion()
math.randomseed(os.time()) math.randomseed(os.time())

View File

@ -1,10 +1,9 @@
local guidReferenceApi = require("core/GUIDReferenceApi")
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenArrangerApi = require("accessories/TokenArrangerApi")
local tokenChecker = require("core/token/TokenChecker") local tokenChecker = require("core/token/TokenChecker")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
local guidHandler = getObjectFromGUID("123456")
local ENCOUNTER_DECK_AREA = { local ENCOUNTER_DECK_AREA = {
upperLeft = { x = 0.9, z = 0.42 }, upperLeft = { x = 0.9, z = 0.42 },
lowerRight = { x = 0.86, z = 0.38 }, lowerRight = { x = 0.86, z = 0.38 },
@ -35,8 +34,8 @@ function onLoad(saveState)
useFrontData = loadedState.useFrontData or true useFrontData = loadedState.useFrontData or true
tokenData = loadedState.tokenData or {} tokenData = loadedState.tokenData or {}
end end
TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
DATA_HELPER = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" }) DATA_HELPER = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper")
collisionEnabled = true collisionEnabled = true
end end

View File

@ -1,9 +1,9 @@
do do
local MythosAreaApi = {} local MythosAreaApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getMythosArea() local function getMythosArea()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "MythosArea")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "MythosArea" })
end end
-- returns the chaos token metadata (if provided through scenario reference card) -- returns the chaos token metadata (if provided through scenario reference card)

View File

@ -1,9 +1,9 @@
do do
local NavigationOverlayApi = {} local NavigationOverlayApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getNOHandler() local function getNOHandler()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "NavigationOverlayHandler")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "NavigationOverlayHandler" })
end end
-- Copies the visibility for the Navigation overlay -- Copies the visibility for the Navigation overlay

View File

@ -44,6 +44,7 @@ local LOC_LINK_EXCLUDE_SCENARIOS = {
["The Heart of Madness"] = true ["The Heart of Madness"] = true
} }
local guidReferenceApi = require("core/GUIDReferenceApi")
local tokenManager = require("core/token/TokenManager") local tokenManager = require("core/token/TokenManager")
local clueData = {} local clueData = {}
@ -513,8 +514,7 @@ function shiftContentsRight(playerColor)
end end
function shiftContents(playerColor, direction) function shiftContents(playerColor, direction)
local guidHandler = getObjectFromGUID("123456") local zone = guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayAreaZone")
local zone = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayAreaZone" })
if not zone then if not zone then
broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red") broadcastToColor("Scripting zone couldn't be found.", playerColor, "Red")
return return

View File

@ -1,14 +1,13 @@
do do
local PlayAreaApi = {} local PlayAreaApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getPlayArea() local function getPlayArea()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "PlayArea")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "PlayArea" })
end end
local function getInvestigatorCounter() local function getInvestigatorCounter()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "InvestigatorCounter")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "InvestigatorCounter" })
end end
-- Returns the current value of the investigator counter from the playmat -- Returns the current value of the investigator counter from the playmat

View File

@ -1,5 +1,6 @@
do do
local SoundCubeApi = {} local SoundCubeApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
-- this table links the name of a trigger effect to its index -- this table links the name of a trigger effect to its index
local soundIndices = { local soundIndices = {
@ -9,8 +10,7 @@ do
} }
local function playTriggerEffect(index) local function playTriggerEffect(index)
local guidHandler = getObjectFromGUID("123456") local SoundCube = guidReferenceApi.getObjectByOwnerAndType("Mythos", "SoundCube")
local SoundCube = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "SoundCube" })
SoundCube.AssetBundle.playTriggerEffect(index) SoundCube.AssetBundle.playTriggerEffect(index)
end end

View File

@ -1,4 +1,5 @@
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local tokenChecker = require("core/token/TokenChecker") local tokenChecker = require("core/token/TokenChecker")
@ -10,8 +11,6 @@ local countedVP = {}
local highlightMissing = false local highlightMissing = false
local highlightCounted = false local highlightCounted = false
local guidHandler = getObjectFromGUID("123456")
-- button creation when loading the game -- button creation when loading the game
function onLoad() function onLoad()
-- index 0: VP - "Display" -- index 0: VP - "Display"
@ -250,7 +249,7 @@ end
-- places the provided card in the first empty spot -- places the provided card in the first empty spot
function placeCard(card) function placeCard(card)
local TRASH = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "Trash" }) local trash = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
-- check snap point states -- check snap point states
local snaps = self.getSnapPoints() local snaps = self.getSnapPoints()
@ -281,7 +280,7 @@ function placeCard(card)
local chaosBag = chaosBagApi.findChaosBag() local chaosBag = chaosBagApi.findChaosBag()
chaosBag.putObject(obj) chaosBag.putObject(obj)
elseif obj.memo ~= nil and obj.getLock() == false then elseif obj.memo ~= nil and obj.getLock() == false then
TRASH.putObject(obj) trash.putObject(obj)
end end
end end
@ -325,13 +324,3 @@ function checkSnapPointState(pos)
origin = pos origin = pos
}) })
end end
-- search a table for a value, return true if found (else returns false)
function tableContains(table, value)
for _, v in ipairs(table) do
if v == value then
return true
end
end
return false
end

View File

@ -1,9 +1,9 @@
do do
local VictoryDisplayApi = {} local VictoryDisplayApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getVictoryDisplay() local function getVictoryDisplay()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "VictoryDisplay")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "VictoryDisplay" })
end end
-- triggers an update of the Victory count -- triggers an update of the Victory count

View File

@ -1,4 +1,5 @@
do do
local guidReferenceApi = require("core/GUIDReferenceApi")
local optionPanelApi = require("core/OptionPanelApi") local optionPanelApi = require("core/OptionPanelApi")
local playAreaApi = require("core/PlayAreaApi") local playAreaApi = require("core/PlayAreaApi")
local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi")
@ -336,8 +337,7 @@ do
return return
end end
tokenTemplates = {} tokenTemplates = {}
local guidHandler = getObjectFromGUID("123456") local tokenSource = guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenSource")
local tokenSource = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSource" })
for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do for _, tokenTemplate in ipairs(tokenSource.getData().ContainedObjects) do
local tokenName = tokenTemplate.Memo local tokenName = tokenTemplate.Memo
tokenTemplates[tokenName] = tokenTemplate tokenTemplates[tokenName] = tokenTemplate
@ -349,8 +349,7 @@ do
if playerCardData ~= nil then if playerCardData ~= nil then
return return
end end
local guidHandler = getObjectFromGUID("123456") local dataHelper = guidReferenceApi.getObjectByOwnerAndType("Mythos", "DataHelper")
local dataHelper = guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "DataHelper" })
playerCardData = dataHelper.getTable('PLAYER_CARD_DATA') playerCardData = dataHelper.getTable('PLAYER_CARD_DATA')
locationData = dataHelper.getTable('LOCATIONS_DATA') locationData = dataHelper.getTable('LOCATIONS_DATA')
end end

View File

@ -53,19 +53,7 @@ end
-- Listener to reset card token spawns when they enter a hand. -- Listener to reset card token spawns when they enter a hand.
function onObjectEnterZone(zone, enterObject) function onObjectEnterZone(zone, enterObject)
if checkMemo(zone) then if zone.type == "Hand" and enterObject.type == "Card" then
resetTokensSpawned(enterObject.getGUID()) resetTokensSpawned(enterObject.getGUID())
end end
end end
-- checks if the object is owned by a playermat
function checkMemo(obj)
local memo = obj.getMemo()
if memo then
local decoded = JSON.decode(memo) or {}
if decoded.matColor ~= "Mythos" then
return true
end
end
return false
end

View File

@ -1,9 +1,9 @@
do do
local TokenSpawnTracker = {} local TokenSpawnTracker = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getSpawnTracker() local function getSpawnTracker()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "TokenSpawnTracker")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "TokenSpawnTracker" })
end end
TokenSpawnTracker.hasSpawnedTokens = function(cardGuid) TokenSpawnTracker.hasSpawnedTokens = function(cardGuid)

View File

@ -3,6 +3,7 @@ do
require("core/tour/TourCard") require("core/tour/TourCard")
local TourManager = {} local TourManager = {}
local internal = {} local internal = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
-- Base IDs for various tour card UI elements. Actual IDs will have _[playerColor] appended -- Base IDs for various tour card UI elements. Actual IDs will have _[playerColor] appended
local CARD_ID = "tourCard" local CARD_ID = "tourCard"
@ -123,9 +124,9 @@ do
delay = delay + 0.5 delay = delay + 0.5
end end
local lookPos local lookPos
if TOUR_SCRIPT[cardIndex].objReferenceData ~= nil then local objReferenceData = TOUR_SCRIPT[cardIndex].objReferenceData
local guidHandler = getObjectFromGUID("123456") if objReferenceData ~= nil then
local lookAtObj = guidHandler.call("getObjectByOwnerAndType", TOUR_SCRIPT[cardIndex].objReferenceData) local lookAtObj = guidReferenceApi.getObjectByOwnerAndType(objReferenceData.owner, objReferenceData.type)
lookPos = lookAtObj.getPosition() lookPos = lookAtObj.getPosition()
lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0 lookPos.y = TOUR_SCRIPT[cardIndex].distanceFromObj or 0
-- Since camera isn't directly above the hook, changing the Y affects the visual position of -- Since camera isn't directly above the hook, changing the Y affects the visual position of

View File

@ -1,9 +1,9 @@
do do
local AllCardsBagApi = {} local AllCardsBagApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
local function getAllCardsBag() local function getAllCardsBag()
local guidHandler = getObjectFromGUID("123456") return guidReferenceApi.getObjectByOwnerAndType("Mythos", "AllCardsBag")
return guidHandler.call("getObjectByOwnerAndType", { owner = "Mythos", type = "AllCardsBag" })
end end
-- Returns a specific card from the bag, based on ArkhamDB ID -- Returns a specific card from the bag, based on ArkhamDB ID

View File

@ -26,16 +26,15 @@ end
-- Activated once per second, counts items in bowls -- Activated once per second, counts items in bowls
function countItems() function countItems()
local totalValue = 0 local totalValue = 0
local countableItems = findValidItemsInSphere() for _, item in ipairs(findValidItemsInSphere()) do
for _, entry in ipairs(countableItems) do local descValue = tonumber(item.getDescription())
local descValue = tonumber(entry.hit_object.getDescription()) local stackMult = math.abs(item.getQuantity())
local stackMult = math.abs(entry.hit_object.getQuantity())
-- Use value in description if available -- Use value in description if available
if descValue ~= nil then if descValue ~= nil then
totalValue = totalValue + descValue * stackMult totalValue = totalValue + descValue * stackMult
else else
-- Otherwise use the value in validCountItemList -- Otherwise use the value in validCountItemList
totalValue = totalValue + validCountItemList[entry.hit_object.getName()] * stackMult totalValue = totalValue + validCountItemList[item.getName()] * stackMult
end end
end end
exposedValue = totalValue exposedValue = totalValue
@ -51,18 +50,15 @@ function findValidItemsInSphere()
size = { 2, 2, 2 } size = { 2, 2, 2 }
}) })
retval = {} local validItemList = {}
for _, entry in ipairs(items) do for _, entry in ipairs(items) do
--Ignore the bowl
if entry.hit_object ~= self then if entry.hit_object ~= self then
--Ignore if not in validCountItemList if validCountItemList[entry.hit_object.getName()] ~= nil then
local tableEntry = validCountItemList[entry.hit_object.getName()] table.insert(validItemList, entry.hit_object)
if tableEntry ~= nil then
table.insert(retval, entry)
end end
end end
end end
return retval return validItemList
end end
function removeAllClues(trash) function removeAllClues(trash)

View File

@ -1,11 +1,10 @@
local chaosBagApi = require("chaosbag/ChaosBagApi") local chaosBagApi = require("chaosbag/ChaosBagApi")
local guidReferenceApi = require("core/GUIDReferenceApi")
local mythosAreaApi = require("core/MythosAreaApi") local mythosAreaApi = require("core/MythosAreaApi")
local navigationOverlayApi = require("core/NavigationOverlayApi") local navigationOverlayApi = require("core/NavigationOverlayApi")
local tokenChecker = require("core/token/TokenChecker") local tokenChecker = require("core/token/TokenChecker")
local tokenManager = require("core/token/TokenManager") local tokenManager = require("core/token/TokenManager")
local guidHandler = getObjectFromGUID("123456")
-- set true to enable debug logging and show Physics.cast() -- set true to enable debug logging and show Physics.cast()
local DEBUG = false local DEBUG = false
@ -105,7 +104,7 @@ function onLoad(saveState)
self.interactable = DEBUG self.interactable = DEBUG
-- get object references to owned objects -- get object references to owned objects
ownedObjects = guidHandler.call("getObjectsByOwner", matColor) ownedObjects = guidReferenceApi.getObjectsByOwner(matColor)
-- button creation -- button creation
for i = 1, 6 do for i = 1, 6 do

View File

@ -1,15 +1,15 @@
do do
local PlaymatApi = {} local PlaymatApi = {}
local guidReferenceApi = require("core/GUIDReferenceApi")
-- 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.
---@param matColor String Color of the playmat - White, Orange, Green, Red or All ---@param matColor String Color of the playmat - White, Orange, Green, Red or All
---@return array Table Single-element if only single playmat is requested ---@return array Table Single-element if only single playmat is requested
local function getMatForColor(matColor) local function getMatForColor(matColor)
local guidHandler = getObjectFromGUID("123456")
if matColor == "All" then if matColor == "All" then
return guidHandler.call("getObjectsByType", "Playermat") return guidReferenceApi.getObjectsByType("Playermat")
else else
return { matColor = guidHandler.call("getObjectByOwnerAndType", { owner = matColor, type = "Playermat" }) } return { matColor = guidReferenceApi.getObjectByOwnerAndType(matColor, "Playermat") }
end end
end end