Originally Posted by SDPhantom
Assuming your :get() and :set() functions are working correctly, this is a simpler method.
Lua Code:
["onclick"]=function(self) local newvalue=self.options[Wrap((tIndexOf(self.options,self:get()) or 0))+1,#self.options)]; self.valueText:SetText(newvalue); self:set(newvalue); end
Note: Both tIndexOf() and Wrap() are Blizzard-defined functions located in SharedXML\TableUtil.lua and SharedXML\MathUtil.lua respectively.
|
more simple for me:
Lua Code:
function own:getnext(tbl, item)
local found
for i = 1, #tbl do
if found then return tbl[i] end
found = tbl[i] == item
end
end