relationTable

Run Settings
LanguageLua
Language Version
Run Command
function relationTableInit(relationTableAttach) assert(type(relationTableAttach) == "table", "relationTableAttach must be a table.") function relationTableAttach.relation(...) local args = {...} assert(#args > 1, "You can't get a relation from a single object.") table.sort(args) local inTable = relationTableAttach[args[1]].relationTable assert(relationTableAttach[args[1]].relationTable, "relationTable Does not exist for: \""..args[1].."\"") for i = 2, #args do assert(relationTableAttach[args[i]].relationTable, "relationTable Does not exist for: \""..args[i].."\"") if inTable[args[i]] == nil then inTable[args[i]] = {} end inTable = inTable[args[i]] end return inTable end end vera = { b = {relationTable = {}}, a = {relationTable = {}}, c = {relationTable = {}}, } relationTableInit(vera) -- Pass in the tables instead of the strings? vera.relation("b","a","c").aKey = "Single Value that exist on the relation of a, b and c" print(vera.relation("c","b","a").aKey) -- Access on out of order keys. print(vera.a.relationTable.b.c.aKey) -- Raw access. (Never use this)
Editor Settings
Theme
Key bindings
Full width
Lines