lua - Get value at index in table -


is possible me cycle table asynchronously without checking state? able colors[count % 6] or similar don't need check explicitly state (count) i'm at.

colors = {         red = {max.r,0,0},         green = {0,max.g,0},         blue = {0,0,max.b},         purple = {max.r,0,max.b},         pink = {max.r,0.1*max.g,0.8*max.b},         yellow = {max.r*0.95,max.g*0.64,0.5*max.b}         } 

i have timer callback want go through table 1 color @ time , have if count == 0 setcolor(colors.red) ...

one way use index table:

local index = {"red", "green", "blue", "purple", "pink", "yellow"} 

then can use colors[index[count % 6 + 1]]. downside is, if keys of colors modified, index needs updated manually.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -