resolving comments
This commit is contained in:
parent
efbf9e885f
commit
e1106d2d3d
@ -1,5 +1,5 @@
|
||||
MIN_VALUE = -99
|
||||
MAX_VALUE = 999
|
||||
MIN_VALUE = 0
|
||||
MAX_VALUE = 99
|
||||
val = 0
|
||||
|
||||
function onSave() return JSON.encode(val) end
|
||||
@ -33,23 +33,15 @@ function onLoad(savedData)
|
||||
color = { 0, 0, 0, 0 }
|
||||
})
|
||||
|
||||
if name == "Resource Counter" then
|
||||
self.addContextMenuItem("Set to description", function(color) setToDescription(color) end)
|
||||
end
|
||||
end
|
||||
|
||||
function setToDescription(color)
|
||||
local newVal = tonumber(self.getDescription())
|
||||
if type(newVal) == "number" and newVal <= 99 and newVal >= 0 then
|
||||
updateVal(newVal)
|
||||
else
|
||||
printToColor("Description does not contain a valid number!", color, "Orange")
|
||||
end
|
||||
self.addContextMenuItem("Add 5", function() updateVal(val + 5) end)
|
||||
self.addContextMenuItem("Subtract 5", function() updateVal(val - 5) end)
|
||||
self.addContextMenuItem("Add 10", function() updateVal(val + 10) end)
|
||||
self.addContextMenuItem("Subtract 10", function() updateVal(val - 10) end)
|
||||
end
|
||||
|
||||
function updateVal(newVal)
|
||||
if tonumber(newVal) then
|
||||
val = newVal
|
||||
val = math.min(math.max(newVal, MIN_VALUE), MAX_VALUE)
|
||||
self.editButton({ index = 0, label = tostring(val) })
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user