updated code for better functionality part 2

This commit is contained in:
Zerino 2024-11-16 21:45:19 -03:00
parent f190678d31
commit 7122135ebc
4 changed files with 16 additions and 9 deletions

View File

@ -209,7 +209,9 @@ function tryObjectEnterContainer(container, object)
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(token.getRotation() + Vector(0, 0, 180))
local sizeY = object.getBounds().size.y
token.setPosition(token.getPosition() + Vector(0, 2 * sizeY, 0))
end
end
end
@ -315,7 +317,9 @@ function onPlayerAction(player, action, targets)
for _, pickedCard in ipairs(pickedCards) do
local searchResult = searchLib.onObject(pickedCard, "isTileOrToken")
for _, token in ipairs(searchResult) do
pickedCard.addAttachment(token)
if not token.locked then
pickedCard.addAttachment(token)
end
end
Wait.condition(
function()

View File

@ -101,8 +101,9 @@ function onCollisionEnter(collisionInfo)
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))
--token.setRotation(token.getRotation() + Vector(0, 0, 180))
local sizeY = object.getBounds().size.y
token.setPosition(token.getPosition() + Vector(0, 2 * sizeY, 0))
end
end
end

View File

@ -1278,8 +1278,9 @@ function onCollisionEnter(collisionInfo)
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))
--token.setRotation(token.getRotation() + Vector(0, 0, 180))
local sizeY = object.getBounds().size.y
token.setPosition(token.getPosition() + Vector(0, 2 * sizeY, 0))
end
end
end

View File

@ -25,7 +25,7 @@ do
orientation = rot or { 0, 0, 0 },
type = 3,
size = size,
max_distance = maxDistance or 1
max_distance = maxDistance or 0
})
-- filter the result for matching objects
@ -46,8 +46,9 @@ do
-- searches the area on an object
function SearchLib.onObject(obj, filter, scale)
scale = scale or 1
local pos = obj.getPosition()
local size = obj.getBounds().size:scale(scale):setAt("y", 0)
local sizeY = obj.getBounds().size.y
local pos = obj.getPosition() + Vector(0, sizeY, 0)
local size = obj.getBounds().size:scale(scale):setAt("y", sizeY)
return returnSearchResult(pos, _, size, filter)
end