LUA question.

Jharakn

New Member
Jul 29, 2019
25
0
0
Hi peoples,

I'm slowly learning LUA but I've got a question for the more advanced programmers than me regarding tables in LUA.

My program has a number of tables for a touchscreen moniter i'm developing, looks a bit like:

local button1 = {name="button 1", colour="1", visible=true}
local button2 = {name="button 2", colour="1", visible=false}
local button3 = {name="button 3", colour="2", visible=true}

etc...

what I'm trying to do is reference those tables in a larger table that can hold the information for every button, i've tried adding after the below:

local button = {1=button1, 2=button2, 3=button3}

with the aim of being able to call at some point in a function button[x].name and if say x=2 it'll return "button 2" but when i tried that it just returned nil instead.

Anyone got any ideas?