added well connected to list of supported cards

This commit is contained in:
Chr1Z93 2024-06-26 00:19:37 +02:00
parent 03d5613570
commit 7a1f67d89f

View File

@ -1,10 +1,8 @@
require("playercards/CardsWithHelper") require("playercards/CardsWithHelper")
local playmatApi = require("playermat/PlaymatApi") local playmatApi = require("playermat/PlaymatApi")
local modValue, loopId
local buttonParameters = { local buttonParameters = {
click_function = "toggleCounter", click_function = "shutOff",
tooltip = "disable counter",
function_owner = self, function_owner = self,
position = { 0.88, 0.5, -1.33 }, position = { 0.88, 0.5, -1.33 },
font_size = 150, font_size = 150,
@ -12,7 +10,14 @@ local buttonParameters = {
height = 175 height = 175
} }
function onSave() return JSON.encode({ loopId = loopId }) end local modValue, loopId
function updateSave()
self.script_state = JSON.encode({
isHelperEnabled = isHelperEnabled,
loopId = loopId
})
end
function onLoad(savedData) function onLoad(savedData)
-- use metadata to detect level and adjust modValue accordingly -- use metadata to detect level and adjust modValue accordingly
@ -22,30 +27,31 @@ function onLoad(savedData)
modValue = 4 modValue = 4
end end
if savedData ~= "" then self.addTag("CardWithHelper")
if savedData and savedData ~= "" then
local loadedData = JSON.decode(savedData) local loadedData = JSON.decode(savedData)
if loadedData.loopId then isHelperEnabled = loadedData.isHelperEnabled
self.createButton(buttonParameters) loopId = loadedData.loopId
loopId = Wait.time(updateDisplay, 2, -1)
end end
end checkOptionPanel()
updateDisplay()
self.addContextMenuItem("Toggle Counter", toggleCounter)
end end
function toggleCounter() function initialize()
if loopId ~= nil then self.createButton(buttonParameters)
updateButton()
loopId = Wait.time(updateButton, 2, -1)
end
function shutOff()
if loopId then
Wait.stop(loopId) Wait.stop(loopId)
loopId = nil loopId = nil
self.clearButtons()
else
self.createButton(buttonParameters)
updateDisplay()
loopId = Wait.time(updateDisplay, 2, -1)
end end
self.clearButtons()
end end
function updateDisplay() function updateButton()
local matColor = playmatApi.getMatColorByPosition(self.getPosition()) local matColor = playmatApi.getMatColorByPosition(self.getPosition())
local resources = playmatApi.getCounterValue(matColor, "ResourceCounter") local resources = playmatApi.getCounterValue(matColor, "ResourceCounter")
local count = tostring(math.floor(resources / modValue)) local count = tostring(math.floor(resources / modValue))