Posted 05 December 2013 - 08:28 PM
Hello, I've made a function that allows you to create variable or infinite depth tables: http://pastebin.com/mZJhuTq5
Explanation:
Explanation:
local index = dofile("index") -- assuming you named the file "index"
local t = setmetatable({}, {__index = index(5)}) -- Depth of 5 indices
t[1][2][3][4][5] = 7 -- No attempt to index nil
print(t[1][2][3][4][5]) --> 7
t.thing.hello[{}][function() end][true] = 18 -- can use _any_ key
local t = setmetatable({}, {__index = index(-1)}) -- Depth of -1 makes it infinitely long
t[1][2][3][4][5][6][7][8][9][0] = 6 -- could've kept making it longer if I wanted =P
t.helloworld.lua.cc.foo.bar = "=)" -- can have values with different depths
print(t[1][2][3][4][5][6][7][8][9][0]) --> 6
print(t.helloworld.lua.cc.foo.bar) --> =)
Edited on 05 December 2013 - 07:28 PM