updated code for better functionality
This commit is contained in:
parent
563bee5757
commit
f190678d31
@ -205,6 +205,13 @@ function tryObjectEnterContainer(container, object)
|
||||
-- stop mini cards from forming decks
|
||||
if object.hasTag("Minicard") and container.hasTag("Minicard") then
|
||||
return false
|
||||
elseif object.getName() ~= "Atlach-Nacha" and next(object.getAttachments()) ~= nil then
|
||||
local removedTokens = object.removeAttachments()
|
||||
if object.is_face_down then
|
||||
for _, token in ipairs(removedTokens) do
|
||||
token.setPosition(token.getPosition() + Vector(0, 0.5, 0))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
playAreaApi.tryObjectEnterContainer(container, object)
|
||||
@ -306,26 +313,22 @@ function onPlayerAction(player, action, targets)
|
||||
end
|
||||
if #pickedCards < 6 then
|
||||
for _, pickedCard in ipairs(pickedCards) do
|
||||
local hitList = Physics.cast({
|
||||
origin = pickedCard.getPosition(),
|
||||
direction = {0,1,0},
|
||||
type = 3,
|
||||
size = Vector(2.4, 0, 3.4),
|
||||
orientation = pickedCard.getRotation(),
|
||||
max_distance = 0.5,
|
||||
})
|
||||
for _, token in ipairs(hitList) do
|
||||
local pickedToken = token.hit_object
|
||||
if pickedToken.type == "Tile" then
|
||||
pickedCard.addAttachment(pickedToken)
|
||||
end
|
||||
local searchResult = searchLib.onObject(pickedCard, "isTileOrToken")
|
||||
for _, token in ipairs(searchResult) do
|
||||
pickedCard.addAttachment(token)
|
||||
end
|
||||
Wait.condition(
|
||||
function()
|
||||
pickedCard.removeAttachments()
|
||||
if pickedCard ~= nil then
|
||||
pickedCard.removeAttachments()
|
||||
end
|
||||
end,
|
||||
function()
|
||||
return pickedCard.resting and not tableContains(player.getHoldingObjects(), pickedCard)
|
||||
if pickedCard ~= nil and player ~= nil and player.seated then
|
||||
return pickedCard.resting and not tableContains(player.getHoldingObjects(), pickedCard)
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
)
|
||||
end
|
||||
|
@ -97,6 +97,15 @@ function onCollisionEnter(collisionInfo)
|
||||
if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then
|
||||
-- reset spawned tokens and remove tokens from cards in encounter deck / discard area
|
||||
Wait.frames(function() tokenSpawnTrackerApi.resetTokensSpawned(object) end, 1)
|
||||
if next(object.getAttachments()) ~= nil then
|
||||
local removedTokens = object.removeAttachments()
|
||||
if object.is_face_down then
|
||||
for _, token in ipairs(removedTokens) do
|
||||
token.setPosition(token.getPosition() + Vector(0, 0.5, 0))
|
||||
token.setRotation(Vector(0, 0, 180))
|
||||
end
|
||||
end
|
||||
end
|
||||
removeTokensFromObject(object)
|
||||
|
||||
elseif inArea(localPos, SCENARIO_REFERENCE_AREA) then
|
||||
@ -308,9 +317,11 @@ end
|
||||
-- removes tokens from the provided card/deck
|
||||
function removeTokensFromObject(object)
|
||||
local TRASH = guidReferenceApi.getObjectByOwnerAndType("Mythos", "Trash")
|
||||
for _, obj in ipairs(searchLib.onObject(object, "isTileOrToken")) do
|
||||
for _, obj in ipairs(searchLib.onObject(object)) do
|
||||
if obj.getGUID() ~= "4ee1f2" and -- table
|
||||
obj ~= self and
|
||||
obj.type ~= "Deck" and
|
||||
obj.type ~= "Card" and
|
||||
obj.memo ~= nil and
|
||||
obj.getLock() == false and
|
||||
not tokenChecker.isChaosToken(obj) then
|
||||
|
@ -1274,6 +1274,15 @@ function onCollisionEnter(collisionInfo)
|
||||
end
|
||||
|
||||
elseif inArea(localCardPos, DECK_DISCARD_AREA) then
|
||||
if next(object.getAttachments()) ~= nil then
|
||||
local removedTokens = object.removeAttachments()
|
||||
if object.is_face_down then
|
||||
for _, token in ipairs(removedTokens) do
|
||||
token.setPosition(token.getPosition() + Vector(0, 0.5, 0))
|
||||
token.setRotation(Vector(0, 0, 180))
|
||||
end
|
||||
end
|
||||
end
|
||||
tokenSpawnTrackerApi.resetTokensSpawned(object)
|
||||
removeTokensFromObject(object)
|
||||
|
||||
|
@ -25,7 +25,7 @@ do
|
||||
orientation = rot or { 0, 0, 0 },
|
||||
type = 3,
|
||||
size = size,
|
||||
max_distance = maxDistance or 0
|
||||
max_distance = maxDistance or 1
|
||||
})
|
||||
|
||||
-- filter the result for matching objects
|
||||
@ -47,7 +47,7 @@ do
|
||||
function SearchLib.onObject(obj, filter, scale)
|
||||
scale = scale or 1
|
||||
local pos = obj.getPosition()
|
||||
local size = obj.getBounds().size:scale(scale):setAt("y", 1)
|
||||
local size = obj.getBounds().size:scale(scale):setAt("y", 0)
|
||||
return returnSearchResult(pos, _, size, filter)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user