first pass

This commit is contained in:
dscarpac 2024-08-15 16:46:24 -05:00
parent 1ef6c641a1
commit 46664a0375
2 changed files with 42 additions and 2 deletions

View File

@ -26,6 +26,7 @@ local currentScenario, useFrontData, tokenData
function onSave() function onSave()
return JSON.encode({ return JSON.encode({
scenarioCardGUID = scenarioCardGUID,
currentScenario = currentScenario, currentScenario = currentScenario,
useFrontData = useFrontData, useFrontData = useFrontData,
tokenData = tokenData tokenData = tokenData
@ -35,6 +36,7 @@ end
function onLoad(savedData) function onLoad(savedData)
if savedData and savedData ~= "" then if savedData and savedData ~= "" then
local loadedState = JSON.decode(savedData) or {} local loadedState = JSON.decode(savedData) or {}
scenarioCard = getObjectFromGUID(loadedState.scenarioCardGUID) or {}
currentScenario = loadedState.currentScenario or "" currentScenario = loadedState.currentScenario or ""
useFrontData = loadedState.useFrontData or true useFrontData = loadedState.useFrontData or true
tokenData = loadedState.tokenData or {} tokenData = loadedState.tokenData or {}
@ -42,6 +44,29 @@ function onLoad(savedData)
Wait.time(function() collisionEnabled = true end, 0.1) Wait.time(function() collisionEnabled = true end, 0.1)
end 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 -- collison and container event handling
--------------------------------------------------------- ---------------------------------------------------------
@ -52,8 +77,8 @@ function onCollisionEnter(collisionInfo)
local object = collisionInfo.collision_object local object = collisionInfo.collision_object
-- early exit for better performance -- early exit for better performance (but should exclude Tiles again in 4.0)
if object.type ~= "Card" then return end if object.type ~= "Card" and object.type ~= "Tile" then return end
-- reset spawned tokens and remove tokens from cards in encounter deck / discard area -- reset spawned tokens and remove tokens from cards in encounter deck / discard area
local localPos = self.positionToLocal(object.getPosition()) local localPos = self.positionToLocal(object.getPosition())
@ -70,6 +95,7 @@ function onCollisionEnter(collisionInfo)
local cardName = object.getName() local cardName = object.getName()
if object.getName() == "Scenario" or md.type == "ScenarioReference" then if object.getName() == "Scenario" or md.type == "ScenarioReference" then
getDataFromReferenceCard(object, cardName, md) getDataFromReferenceCard(object, cardName, md)
scenarioCard = object
end end
end end
@ -108,6 +134,7 @@ function onCollisionExit(collisionInfo)
tokenData = {} tokenData = {}
useFrontData = nil useFrontData = nil
fireTokenDataChangedEvent() fireTokenDataChangedEvent()
scenarioCard = nil
end end
end end

View File

@ -10,3 +10,16 @@
textAlignment="MiddleCenter" textAlignment="MiddleCenter"
onClick="reshuffleEncounterDeck">Reshuffle ➡</Button> onClick="reshuffleEncounterDeck">Reshuffle ➡</Button>
</Panel> </Panel>
<Panel position="-160 70 -11"
rotation="0 0 180"
height="74"
width="400">
<Button scale="0.1 0.1 1"
color="#ffffff00"
textColors="#ffffff|#88e3cf|#4f8478"
font="font_teutonic-arkham"
fontSize="62"
textAlignment="MiddleCenter"
onClick="copyScenarioReferenceCard">Copy to Playermats</Button>
</Panel>