local function getIndex(t, i)
local fi = i[1]
local ni = {}
for key, value in pairs(i) do
ni[key - 1] = value
end
print(#ni .. ": " .. fi)
if #ni == 0 then
return t[fi]
end
return getIndex(t[fi], ni)
end
local a = {b = {c = {"lol"}}}
local b = {"a", "b", "c", 1}
local result = getIndex(a, b )
print(result)
It errors with "test:11: attempt to index (a nil value)". I know this error means the table "t" doesn't exists, but I can't figure out why.EDIT: The error doesn't occurs the first time the function runs. The debug print at line 7 prints out the following:
3: a 2: b
Edited by flaghacker, 29 July 2014 - 10:21 AM.












