• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

retrieving table data

guisalum

New Member
Joined
Dec 22, 2009
Messages
22
Reaction score
0
I'd like to retrive data from a table but instead of using the exact word I'd like to use a variable.

For example

Code:
variableSon = "sons"

local table = {mother = "mom", sons = {first = "jack", middle = "John", last = "Jonathan"}}

So intead of using table.sons.first I want to use the variable

example

table.variableSon.first

Is it possible?
 
Code:
local var = "sons"
local table = {
	["sons"] = {first = "jack", second = "alan"},
	mother = "Mom"
}

print (unpack ( table[var] ) )
 
Back
Top