Originally Posted by Kanegasi
Every time you click, that function is looping through the whole options table, from ONE to FOUR, calling SetText() and set() for each one. No matter how many times you click, you will always see FOUR, while the other three attempted to show within the frame you clicked.
I'm going to assume your default value is also in this frame since options is there.
Lua Code:
function(self) local valueset if not self.firstload then self.firstload=true valueset=self.value for k,v in ipairs(self.options) do if v=self.value then self.lastindex=k end end else valueset=self.options[#self.options==self.lastindex and 1 or self.lastindex+1] end self.valueText:SetText(valueset) self:set(valueset) end
|
Thx for answer! But it only fires twice and stops, if i set self.firstload=false i get loop only between "ONE" and "TWO" values:
Lua Code:
['onclick'] = function(self)
local valueset
-- if (not value) then value = self:get() end
-- self.save[self.key] = valueset
-- self.value =
if not self.firstload then
self.firstload = true
valueset = self.value
for k, v in ipairs(self.options) do
if v == self.value then
self.lastindex = k
print('k')
end
end
else
self.firstload = false -- about this
valueset = self.options[#self.options == self.lastindex and 1 or self.lastindex+1]
print('+1')
end
self.valueText:SetText(valueset)
self:set(valueset)
end,
https://gfycat.com/vibrantorganicbufeo