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
Post a Comment