more fixing
This commit is contained in:
parent
da4a043ff7
commit
515f48b94d
@ -1,5 +1,3 @@
|
|||||||
local tokenManager = require("core/token/TokenManager")
|
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
-- general setup
|
-- general setup
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -25,9 +23,10 @@ local SHIFT_EXCLUSION = {
|
|||||||
["721ba2"] = true
|
["721ba2"] = 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"
|
||||||
|
local lastCollisionObject
|
||||||
local currentScenario
|
local currentScenario
|
||||||
|
|
||||||
---------------------------------------------------------
|
---------------------------------------------------------
|
||||||
@ -64,19 +63,24 @@ function updateLocations(args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function onCollisionEnter(collision_info)
|
function onCollisionEnter(collision_info)
|
||||||
if not COLLISION_ENABLED then return end
|
local obj = collision_info.collision_object
|
||||||
|
|
||||||
|
-- only trigger the following once every 0.1s for each object
|
||||||
|
-- (otherwise TTS fires this event 20 times and that causes 20 JSON decodes)
|
||||||
|
if not COLLISION_ENABLED or lastCollisionObject == obj then return end
|
||||||
|
lastCollisionObject = obj
|
||||||
|
Wait.time(function() lastCollisionObject = nil end, 0.1)
|
||||||
|
|
||||||
-- 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 = collision_info.collision_object
|
if shouldSpawnTokens(obj) then
|
||||||
if shouldSpawnTokens(card) then
|
tokenManager.spawnForCard(obj)
|
||||||
tokenManager.spawnForCard(card)
|
|
||||||
end
|
end
|
||||||
end
|
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"
|
||||||
@ -85,9 +89,8 @@ function shouldSpawnTokens(card)
|
|||||||
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")
|
||||||
|
@ -285,6 +285,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