Self Updating Gauges
Tired of calling setValue all the time? Just want to tell your gauge what variables to watch and have it figure out all that crap? Bonus if it will update the text as well? Self Updating Gauges are for you!
They're not really all that different from Geyser.Gauge, which the self updating gauges extend. The following code creates a health gauge which will monitor the variable gmcp.Char.Vitals.hp for the current value and gmcp.Char.Vitals.maxhp as the max value.
require("MDK-1.sug") --the following will watch "gmcp.Char.Vitals.hp" and "gmcp.Char.Vitals.maxhp" and update itself every 333 milliseconds
myGauge = SUG:new({
name = "myGauge",
currentVariable = "gmcp.Char.Vitals.hp", --if this is nil, it will use the defaultCurrent of 50
maxVariable = "gmcp.Char.Vitals.maxhp", --if this is nil, it will use the defaultMax of 100.
height = 50,
})
SUGs will use tonumber to coerce a variable to a number if possible, so your string gmcp values will be turned into numbers for use by the gauge without you having to do it.