Tables are one of the features of Lua script, that make the scripting language so dynamic & easy to use, as they allow us to easily create tables, insert, remove & sort data. Tables are often comprised of arrays that usually involve keywords - or an index number - & a value. Tables can be accessed using multiple different methods.
localt={1,2,3,4,5,"six",7,"ate",9}-- automatically assigns an index number to each value starting from 1.print("index total = "..#(t))-- print total of table entriesfori=1,#tdo-- for 1 to table total, print value of index numberprint(t[i])end
click to enlarge
method 2: manually created index values
localt={[1]=1[2]="two"[3]=3[4]=2*2[5]="five"}print("index total = "..#(t))-- print total of table entriesfori=1,#tdo-- for 1 to table total, print value of index numberprint(t[i])end