View Single Post
06-05-22, 10:12 AM   #3
nonexistentx_x
A Murloc Raider
 
nonexistentx_x's Avatar
Join Date: Mar 2019
Posts: 8
Originally Posted by Kanegasi View Post
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:
  1. function(self)
  2.     local valueset
  3.     if not self.firstload then
  4.         self.firstload=true
  5.         valueset=self.value
  6.         for k,v in ipairs(self.options) do
  7.             if v=self.value then
  8.                 self.lastindex=k
  9.             end
  10.         end
  11.     else
  12.         valueset=self.options[#self.options==self.lastindex and 1 or self.lastindex+1]
  13.     end
  14.     self.valueText:SetText(valueset)
  15.     self:set(valueset)
  16. 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:
  1. ['onclick'] = function(self)
  2.         local valueset
  3.         -- if (not value) then value = self:get() end
  4.         -- self.save[self.key] = valueset
  5.         -- self.value =
  6.         if not self.firstload then
  7.             self.firstload = true
  8.             valueset = self.value
  9.             for k, v in ipairs(self.options) do
  10.                 if v == self.value then
  11.                     self.lastindex = k
  12.                     print('k')
  13.                 end
  14.             end
  15.         else
  16.             self.firstload = false -- about this
  17.             valueset = self.options[#self.options == self.lastindex and 1 or self.lastindex+1]
  18.             print('+1')
  19.         end
  20.         self.valueText:SetText(valueset)
  21.         self:set(valueset)
  22.     end,

https://gfycat.com/vibrantorganicbufeo
  Reply With Quote