From 46664a0375b827333ab0b0650cde277c8e804317 Mon Sep 17 00:00:00 2001 From: dscarpac Date: Thu, 15 Aug 2024 16:46:24 -0500 Subject: [PATCH] first pass --- src/core/MythosArea.ttslua | 31 +++++++++++++++++++++++++++++-- xml/MythosArea.xml | 13 +++++++++++++ 2 files changed, 42 insertions(+), 2 deletions(-) diff --git a/src/core/MythosArea.ttslua b/src/core/MythosArea.ttslua index 4cb762b7..5243a58a 100644 --- a/src/core/MythosArea.ttslua +++ b/src/core/MythosArea.ttslua @@ -26,6 +26,7 @@ local currentScenario, useFrontData, tokenData function onSave() return JSON.encode({ + scenarioCardGUID = scenarioCardGUID, currentScenario = currentScenario, useFrontData = useFrontData, tokenData = tokenData @@ -35,6 +36,7 @@ end function onLoad(savedData) if savedData and savedData ~= "" then local loadedState = JSON.decode(savedData) or {} + scenarioCard = getObjectFromGUID(loadedState.scenarioCardGUID) or {} currentScenario = loadedState.currentScenario or "" useFrontData = loadedState.useFrontData or true tokenData = loadedState.tokenData or {} @@ -42,6 +44,29 @@ function onLoad(savedData) Wait.time(function() collisionEnabled = true end, 0.1) end +function copyScenarioReferenceCard() + if scenarioCard ~= nil then + usedColors = playermatApi.getUsedMatColors() + if #usedColors ~= 0 then + for _, color in ipairs(usedColors) do + if color == "Green" then + scenarioCard.clone({position = {x = -39.12, y = 1.55, z = 22.58}, snap_to_grid = true}) + elseif color == "Red" then + scenarioCard.clone({position = {x = -21.57, y = 1.55, z = -22.58}, snap_to_grid = true}) + elseif color == "Orange" then + scenarioCard.clone({position = {x = -50.98, y = 1.55, z = -24.87}, snap_to_grid = true}) + else + scenarioCard.clone({position = {x = -50.98, y = 1.55, z = 7.32}, snap_to_grid = true}) + end + end + else + broadcastToAll("No investigators placed.", "Red") + end + else + broadcastToAll("No scenario reference card found.", "Red") + end +end + --------------------------------------------------------- -- collison and container event handling --------------------------------------------------------- @@ -52,8 +77,8 @@ function onCollisionEnter(collisionInfo) local object = collisionInfo.collision_object - -- early exit for better performance - if object.type ~= "Card" then return end + -- early exit for better performance (but should exclude Tiles again in 4.0) + if object.type ~= "Card" and object.type ~= "Tile" then return end -- reset spawned tokens and remove tokens from cards in encounter deck / discard area local localPos = self.positionToLocal(object.getPosition()) @@ -70,6 +95,7 @@ function onCollisionEnter(collisionInfo) local cardName = object.getName() if object.getName() == "Scenario" or md.type == "ScenarioReference" then getDataFromReferenceCard(object, cardName, md) + scenarioCard = object end end @@ -108,6 +134,7 @@ function onCollisionExit(collisionInfo) tokenData = {} useFrontData = nil fireTokenDataChangedEvent() + scenarioCard = nil end end diff --git a/xml/MythosArea.xml b/xml/MythosArea.xml index 15ac038a..9b226a30 100644 --- a/xml/MythosArea.xml +++ b/xml/MythosArea.xml @@ -10,3 +10,16 @@ textAlignment="MiddleCenter" onClick="reshuffleEncounterDeck">Reshuffle ➡ + + + +