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
|
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)
|
function onLoad(savedData)
|
||||||
if savedData and savedData ~= "" then
|
val = tonumber(savedData) or 0
|
||||||
val = JSON.decode(savedData)
|
|
||||||
end
|
|
||||||
|
|
||||||
self.max_typed_number = MAX_VALUE
|
self.max_typed_number = MAX_VALUE
|
||||||
|
|
||||||
local tokenType = self.getMemo()
|
local tokenType = self.getMemo()
|
||||||
@ -51,6 +53,7 @@ function updateVal(newVal)
|
|||||||
if tonumber(newVal) then
|
if tonumber(newVal) then
|
||||||
val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)
|
val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)
|
||||||
self.editButton({ index = 0, label = tostring(val) })
|
self.editButton({ index = 0, label = tostring(val) })
|
||||||
|
updateSave()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -61,6 +64,7 @@ end
|
|||||||
function modifyValue(mod)
|
function modifyValue(mod)
|
||||||
val = math.min(math.max(val + tonumber(mod), MIN_VALUE), MAX_VALUE)
|
val = math.min(math.max(val + tonumber(mod), MIN_VALUE), MAX_VALUE)
|
||||||
self.editButton({ index = 0, label = tostring(val) })
|
self.editButton({ index = 0, label = tostring(val) })
|
||||||
|
updateSave()
|
||||||
end
|
end
|
||||||
|
|
||||||
function onNumberTyped(_, number)
|
function onNumberTyped(_, number)
|
||||||
|
Loading…
Reference in New Issue
Block a user