added well connected to list of supported cards
This commit is contained in:
parent
03d5613570
commit
7a1f67d89f
@ -1,10 +1,8 @@
|
||||
require("playercards/CardsWithHelper")
|
||||
local playmatApi = require("playermat/PlaymatApi")
|
||||
|
||||
local modValue, loopId
|
||||
local buttonParameters = {
|
||||
click_function = "toggleCounter",
|
||||
tooltip = "disable counter",
|
||||
click_function = "shutOff",
|
||||
function_owner = self,
|
||||
position = { 0.88, 0.5, -1.33 },
|
||||
font_size = 150,
|
||||
@ -12,7 +10,14 @@ local buttonParameters = {
|
||||
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)
|
||||
-- use metadata to detect level and adjust modValue accordingly
|
||||
@ -22,30 +27,31 @@ function onLoad(savedData)
|
||||
modValue = 4
|
||||
end
|
||||
|
||||
if savedData ~= "" then
|
||||
self.addTag("CardWithHelper")
|
||||
if savedData and savedData ~= "" then
|
||||
local loadedData = JSON.decode(savedData)
|
||||
if loadedData.loopId then
|
||||
self.createButton(buttonParameters)
|
||||
loopId = Wait.time(updateDisplay, 2, -1)
|
||||
end
|
||||
isHelperEnabled = loadedData.isHelperEnabled
|
||||
loopId = loadedData.loopId
|
||||
end
|
||||
|
||||
self.addContextMenuItem("Toggle Counter", toggleCounter)
|
||||
checkOptionPanel()
|
||||
updateDisplay()
|
||||
end
|
||||
|
||||
function toggleCounter()
|
||||
if loopId ~= nil then
|
||||
function initialize()
|
||||
self.createButton(buttonParameters)
|
||||
updateButton()
|
||||
loopId = Wait.time(updateButton, 2, -1)
|
||||
end
|
||||
|
||||
function shutOff()
|
||||
if loopId then
|
||||
Wait.stop(loopId)
|
||||
loopId = nil
|
||||
self.clearButtons()
|
||||
else
|
||||
self.createButton(buttonParameters)
|
||||
updateDisplay()
|
||||
loopId = Wait.time(updateDisplay, 2, -1)
|
||||
end
|
||||
self.clearButtons()
|
||||
end
|
||||
|
||||
function updateDisplay()
|
||||
function updateButton()
|
||||
local matColor = playmatApi.getMatColorByPosition(self.getPosition())
|
||||
local resources = playmatApi.getCounterValue(matColor, "ResourceCounter")
|
||||
local count = tostring(math.floor(resources / modValue))
|
||||
|
Loading…
Reference in New Issue
Block a user