Merge pull request #143 from argonui/image-swapper-fix
Playmat Image Swapper: Fix variable name and declaration
This commit is contained in:
commit
5e44da3a91
@ -1,5 +1,3 @@
|
|||||||
local tokenManager = require("core/token/TokenManager")
|
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- general setup
|
-- general setup
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -24,6 +22,9 @@ local CONNECTION_LINE_Y = 1.529
|
|||||||
-- we use this to turn off collision handling until onLoad() is complete
|
-- we use this to turn off collision handling until onLoad() is complete
|
||||||
local collisionEnabled = false
|
local collisionEnabled = false
|
||||||
|
|
||||||
|
-- used for recreating the link to a custom data helper after image change
|
||||||
|
customDataHelper = nil
|
||||||
|
|
||||||
local SHIFT_OFFSETS = {
|
local SHIFT_OFFSETS = {
|
||||||
left = { x = 0.00, y = 0, z = 7.67 },
|
left = { x = 0.00, y = 0, z = 7.67 },
|
||||||
right = { 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,
|
["The Witching Hour"] = true,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local tokenManager = require("core/token/TokenManager")
|
||||||
local INVESTIGATOR_COUNTER_GUID = "f182ee"
|
local INVESTIGATOR_COUNTER_GUID = "f182ee"
|
||||||
local PLAY_AREA_ZONE_GUID = "a2f932"
|
local PLAY_AREA_ZONE_GUID = "a2f932"
|
||||||
|
|
||||||
@ -83,14 +85,19 @@ end
|
|||||||
-- data to the local token manager instance.
|
-- data to the local token manager instance.
|
||||||
---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call
|
---@param args Table Single-value array holding the GUID of the Custom Data Helper making the call
|
||||||
function updateLocations(args)
|
function updateLocations(args)
|
||||||
local customDataHelper = getObjectFromGUID(args[1])
|
customDataHelper = getObjectFromGUID(args[1])
|
||||||
if customDataHelper ~= nil then
|
if customDataHelper ~= nil then
|
||||||
tokenManager.addLocationData(customDataHelper.getTable("LOCATIONS_DATA"))
|
tokenManager.addLocationData(customDataHelper.getTable("LOCATIONS_DATA"))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function onCollisionEnter(collisionInfo)
|
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
|
-- check if we should spawn clues here and do so according to playercount
|
||||||
local card = collisionInfo.collision_object
|
local card = collisionInfo.collision_object
|
||||||
if shouldSpawnTokens(card) then
|
if shouldSpawnTokens(card) then
|
||||||
@ -103,7 +110,7 @@ end
|
|||||||
function shouldSpawnTokens(card)
|
function shouldSpawnTokens(card)
|
||||||
local metadata = JSON.decode(card.getGMNotes())
|
local metadata = JSON.decode(card.getGMNotes())
|
||||||
if metadata == nil then
|
if metadata == nil then
|
||||||
return tokenManager.hasLocationData(card) ~= nil
|
return tokenManager.hasLocationData(card)
|
||||||
end
|
end
|
||||||
return metadata.type == "Location"
|
return metadata.type == "Location"
|
||||||
or metadata.type == "Enemy"
|
or metadata.type == "Enemy"
|
||||||
@ -373,9 +380,8 @@ function addArrowLines(arrowheadPos, originPos, lines)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Move all contents on the play area (cards, tokens, etc) one slot in the given direction. Certain
|
-- 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
|
-- fixed objects will be ignored, as will anything the player has tagged with 'displacement_excluded'
|
||||||
-- 'displacement_excluded'
|
---@param playerColor String Color of the player requesting the shift. Used solely to send an error
|
||||||
---@param playerColor 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
|
--- message in the unlikely case that the scripting zone has been deleted
|
||||||
function shiftContentsUp(playerColor)
|
function shiftContentsUp(playerColor)
|
||||||
shiftContents(playerColor, "up")
|
shiftContents(playerColor, "up")
|
||||||
|
@ -104,7 +104,7 @@ function updateSurface(newURL)
|
|||||||
playArea.setCustomObject(customInfo)
|
playArea.setCustomObject(customInfo)
|
||||||
|
|
||||||
-- get custom data helper and call it after reloading
|
-- 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()
|
playArea = playArea.reload()
|
||||||
|
|
||||||
if guid ~= nil then
|
if guid ~= nil then
|
||||||
|
@ -299,6 +299,7 @@ do
|
|||||||
---@param card Object Card to check for data
|
---@param card Object Card to check for data
|
||||||
---@return Boolean True if this card has data in the helper, false otherwise
|
---@return Boolean True if this card has data in the helper, false otherwise
|
||||||
TokenManager.hasLocationData = function(card)
|
TokenManager.hasLocationData = function(card)
|
||||||
|
internal.initDataHelperData()
|
||||||
return internal.getLocationData(card) ~= nil
|
return internal.getLocationData(card) ~= nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user