of     1   

swimmaster07
#183637068Monday, February 15, 2016 2:32 AM GMT

Is it possible to put a table in a table/ For example... local tab1 = {"apple", "orange", "pear"} local tab2 = {tab1}
UnsourcedAnon
#183637773Monday, February 15, 2016 2:41 AM GMT

Certainly. "tables", although data structures, are also a type of data themselves within Lua. Thus, you can index them within another table as you would any other type of data. An example is shown below: Table = {["Tab"]={"Cookies"}}; print(Table.Tab[1]); This would print the string data "Cookies" because "Cookies" is numerically-indexed within the first position of the indexed table.
LilMcManiac
#183641136Monday, February 15, 2016 3:27 AM GMT

local tab1 = {"apple", "orange", "pear"} local tab2 = {unpack(tab1)}
izzatnasruna
#183646343Monday, February 15, 2016 4:35 AM GMT

local t = {1,2,3} local tt = {t,4,5,6} local ttt = {tt,7,8,9} print(unpack(t)) print(unpack(tt[1]),unpack(tt)) print(unpack(ttt[1][1]),unpack(ttt[1]),unpack(ttt))
swimmaster07
#183697332Monday, February 15, 2016 8:53 PM GMT

what does unpack mean?
Wrathsong
#183697381Monday, February 15, 2016 8:54 PM GMT

LilMcManiac
#183697437Monday, February 15, 2016 8:54 PM GMT

unpack is referencing to its name. It unpacks the table, or gets the table's contents and organizing them in the order they were stored in the table. "Some people want it to happen, some wish it would happen, others make it happen" - MJ
128Gigabytes
#183697951Monday, February 15, 2016 9:00 PM GMT

Thats not what unpack does that doesn't even make sense. Unpack turns an array into a tuple.
swimmaster07
#183726241Tuesday, February 16, 2016 2:06 AM GMT

srry but erm, what's a tuple?
swimmaster07
#183729806Tuesday, February 16, 2016 2:53 AM GMT

So lets say that "contestants" is a table with values in it. Could I do... activecontestants = {unpack(contestants)}
LilMcManiac
#183731654Tuesday, February 16, 2016 3:18 AM GMT

^ That should work perfectly fine. "Some people want it to happen, some wish it would happen, others make it happen" - MJ
swimmaster07
#183731790Tuesday, February 16, 2016 3:20 AM GMT

K thx!
LilMcManiac
#183734109Tuesday, February 16, 2016 3:54 AM GMT

Also, a tuple is an unordered set of known values with names. So, now I see what someone above meant. When you unpack a table like below; local table = {1,5,8} print(unpack(table)) The output would be, 1 5 8 It is printing a 'tuple'. A unordered set of known values with names! "Some people want it to happen, some wish it would happen, others make it happen" - MJ
ForeverDev
#183736253Tuesday, February 16, 2016 4:25 AM GMT

Since we're on the topic of tuples, functions can return them too local function thing() return 10, 20 end local a, b = thing() print(a, b) --> 10 20
LilMcManiac
#183736306Tuesday, February 16, 2016 4:26 AM GMT

^ Did not know that! That will help me a lot. "Some people want it to happen, some wish it would happen, others make it happen" - MJ
ForeverDev
#183736467Tuesday, February 16, 2016 4:28 AM GMT

Actually you can do variable assignments with tuples too local a, b, c = 3.14, 42, 13 print(a, b, c) --> 3.14, 42, 13
LilMcManiac
#183736544Tuesday, February 16, 2016 4:29 AM GMT

^ I knew that; I use it all the time. "Some people want it to happen, some wish it would happen, others make it happen" - MJ
128Gigabytes
#183737017Tuesday, February 16, 2016 4:37 AM GMT

Tuples have an order

    of     1