Merge pull request #920 from argonui/counters

Changed save function of counters for better performance
This commit is contained in:
dscarpac 2024-10-24 07:36:26 -05:00 committed by GitHub
commit 40a3bba7ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,13 +1,15 @@
local MIN_VALUE, MAX_VALUE = 0, 99
val = 0
function onSave() return JSON.encode(val) end
function onLoad(savedData)
if savedData and savedData ~= "" then
val = JSON.decode(savedData)
function onDestroy()
updateSave()
end
function updateSave()
self.script_state = val
end
function onLoad(savedData)
val = tonumber(savedData) or 0
self.max_typed_number = MAX_VALUE
local tokenType = self.getMemo()
@ -51,6 +53,7 @@ function updateVal(newVal)
if tonumber(newVal) then
val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)
self.editButton({ index = 0, label = tostring(val) })
updateSave()
end
end
@ -61,6 +64,7 @@ end
function modifyValue(mod)
val = math.min(math.max(val + tonumber(mod), MIN_VALUE), MAX_VALUE)
self.editButton({ index = 0, label = tostring(val) })
updateSave()
end
function onNumberTyped(_, number)