Referencing objects base on a variable

Is there a way to reference objects in Lua, not directly, but based on a condition or variable. Something like:

light1.IsVisible = false  
light2.IsVisible = false  
light3.IsVisible = false  
local function LightUp ()  
  
 local i = math.random (3)  
  
 light.i.IsVisible = true -- i.e., which light turns on depends on i  
  
end  
  

Thanks again.
[import]uid: 78150 topic_id: 21864 reply_id: 321864[/import]

Sure like this :

[code]
local light = {
{isVisible = false},
{isVisible = false},
{isVisible = false},
}

local function LightUp ()

local i = math.random (3)

light[i].isVisible = true – i.e., which light turns on depends on i

end [import]uid: 84637 topic_id: 21864 reply_id: 86921[/import]