From cc7b0d0e631aa5253c857e8a58cec662d24853a6 Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 11 May 2023 15:37:25 +0200 Subject: [PATCH 1/2] automatic token discarding --- src/core/MythosArea.ttslua | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 61fd1ca6..7822859f 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -1,6 +1,7 @@ local playAreaApi = require("core/PlayAreaApi") local tokenArrangerApi = require("accessories/TokenArrangerApi") local tokenSpawnTrackerApi = require("core/token/TokenSpawnTrackerApi") +local tokenChecker = require("core/token/TokenChecker") local ENCOUNTER_DECK_AREA = { upperLeft = { x = 0.9, z = 0.42 }, @@ -15,6 +16,9 @@ local currentScenario local useFrontData local tokenData +local TRASHCAN +local TRASHCAN_GUID = "70b9f6" + -- we use this to turn off collision handling until onLoad() is complete local collisionEnabled = false @@ -25,6 +29,7 @@ function onLoad(saveState) useFrontData = loadedState.useFrontData or true tokenData = loadedState.tokenData or {} end + TRASHCAN = getObjectFromGUID(TRASHCAN_GUID) collisionEnabled = true end @@ -74,6 +79,7 @@ function onCollisionEnter(collisionInfo) local localPos = self.positionToLocal(object.getPosition()) if inArea(localPos, ENCOUNTER_DECK_AREA) or inArea(localPos, ENCOUNTER_DISCARD_AREA) then tokenSpawnTrackerApi.resetTokensSpawned(object.getGUID()) + removeTokensFromObject(object) end end @@ -131,3 +137,31 @@ function inArea(point, bounds) and point.z < bounds.upperLeft.z and point.z > bounds.lowerRight.z) end + +-- removes tokens from the provided card/deck +function removeTokensFromObject(object) + for _, v in ipairs(searchArea(object.getPosition(), { 3, 1, 4 })) do + local obj = v.hit_object + + 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 + TRASHCAN.putObject(obj) + end + end +end + +function searchArea(origin, size) + return Physics.cast({ + origin = origin, + direction = {0, 1, 0}, + orientation = self.getRotation(), + type = 3, + size = size, + max_distance = 1 + }) +end \ No newline at end of file From c1a3821530f03ce0822e60c1d9b301215c8fc77d Mon Sep 17 00:00:00 2001 From: Chr1Z93 Date: Thu, 11 May 2023 15:42:36 +0200 Subject: [PATCH 2/2] fixed EoF LB --- src/core/MythosArea.ttslua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 7822859f..fd0c7117 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -164,4 +164,4 @@ function searchArea(origin, size) size = size, max_distance = 1 }) -end \ No newline at end of file +end