View Single Post
06-05-22, 07:07 AM   #1
nonexistentx_x
A Murloc Raider
 
nonexistentx_x's Avatar
Join Date: Mar 2019
Posts: 8
simple table loop

Hello. I'm trying to do simple loop table, but it doesn't quite work...
What i want? - Output value each time from my table through onclick function. For example:
We have some table like:
Lua Code:
  1. value = "TWO", -- default
  2. options = { "ONE", "TWO", "THREE", "FOUR" },

and ipairs this table:
Lua Code:
  1. ['onclick'] = function(self)
  2.         for k, v in ipairs(self.options) do
  3.             self.valueText:SetText(v)
  4.             self:set(v)
  5.         end
  6.         -- self.callback(self.check)
  7.     end,
but when i click it changes the value only once, to the latest one and stop.
How to make it change every time on click? (e.g if "TWO" --> set "THREE", or if "FOUR" then set "ONE" and loop again)
  Reply With Quote