Merge pull request #920 from argonui/counters
Changed save function of counters for better performance
This commit is contained in:
commit
40a3bba7ce
@ -1,13 +1,15 @@
|
||||
local MIN_VALUE, MAX_VALUE = 0, 99
|
||||
val = 0
|
||||
|
||||
function onSave() return JSON.encode(val) end
|
||||
function onDestroy()
|
||||
updateSave()
|
||||
end
|
||||
|
||||
function updateSave()
|
||||
self.script_state = val
|
||||
end
|
||||
|
||||
function onLoad(savedData)
|
||||
if savedData and savedData ~= "" then
|
||||
val = JSON.decode(savedData)
|
||||
end
|
||||
|
||||
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)
|
||||
|
Loading…
Reference in New Issue
Block a user