diff --git a/src/core/PlayArea.ttslua b/src/core/PlayArea.ttslua index 3fa91628..ba772aa9 100644 --- a/src/core/PlayArea.ttslua +++ b/src/core/PlayArea.ttslua @@ -1,5 +1,3 @@ -local tokenManager = require("core/token/TokenManager") - --------------------------------------------------------- -- general setup --------------------------------------------------------- @@ -24,6 +22,9 @@ local CONNECTION_LINE_Y = 1.529 -- we use this to turn off collision handling until onLoad() is complete local collisionEnabled = false +-- used for recreating the link to a custom data helper after image change +customDataHelper = nil + local SHIFT_OFFSETS = { left = { x = 0.00, y = 0, z = 7.67 }, right = { x = 0.00, y = 0, z = -7.67 }, @@ -40,6 +41,7 @@ local LOC_LINK_EXCLUDE_SCENARIOS = { ["The Witching Hour"] = true, } +local tokenManager = require("core/token/TokenManager") local INVESTIGATOR_COUNTER_GUID = "f182ee" local PLAY_AREA_ZONE_GUID = "a2f932" @@ -83,14 +85,19 @@ end -- data to the local token manager instance. ---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call function updateLocations(args) - local customDataHelper = getObjectFromGUID(args[1]) + customDataHelper = getObjectFromGUID(args[1]) if customDataHelper ~= nil then tokenManager.addLocationData(customDataHelper.getTable("LOCATIONS_DATA")) end end function onCollisionEnter(collisionInfo) - if not collisionEnabled then return end + local obj = collisionInfo.collision_object + local objType = obj.name + + -- only continue for cards + if not collisionEnabled or (objType ~= "Card" and objType ~= "CardCustom") then return end + -- check if we should spawn clues here and do so according to playercount local card = collisionInfo.collision_object if shouldSpawnTokens(card) then @@ -103,7 +110,7 @@ end function shouldSpawnTokens(card) local metadata = JSON.decode(card.getGMNotes()) if metadata == nil then - return tokenManager.hasLocationData(card) ~= nil + return tokenManager.hasLocationData(card) end return metadata.type == "Location" or metadata.type == "Enemy" @@ -373,9 +380,8 @@ function addArrowLines(arrowheadPos, originPos, lines) end -- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain --- fixed objects will be ignored, as will anything the player has tagged with --- 'displacement_excluded' ----@param playerColor Color of the player requesting the shift. Used solely to send an error +-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded' +---@param playerColor String Color of the player requesting the shift. Used solely to send an error --- message in the unlikely case that the scripting zone has been deleted function shiftContentsUp(playerColor) shiftContents(playerColor, "up") diff --git a/src/core/PlayAreaSelector.ttslua b/src/core/PlayAreaSelector.ttslua index 5af68527..d100ecc9 100644 --- a/src/core/PlayAreaSelector.ttslua +++ b/src/core/PlayAreaSelector.ttslua @@ -104,7 +104,7 @@ function updateSurface(newURL) playArea.setCustomObject(customInfo) -- get custom data helper and call it after reloading - local guid = playArea.getVar("custom_data_helper_guid") + local guid = playArea.getVar("customDataHelper") playArea = playArea.reload() if guid ~= nil then diff --git a/src/core/token/TokenManager.ttslua b/src/core/token/TokenManager.ttslua index 14bd260a..256aa9c4 100644 --- a/src/core/token/TokenManager.ttslua +++ b/src/core/token/TokenManager.ttslua @@ -299,6 +299,7 @@ do ---@param card Object Card to check for data ---@return Boolean True if this card has data in the helper, false otherwise TokenManager.hasLocationData = function(card) + internal.initDataHelperData() return internal.getLocationData(card) ~= nil end