The full error code
test:26: vm error:
java.lang.ArrayIndexOutOFBoundsException: 256
the full code for test
Spoiler
function meta(func)
local metaTable = {}
local metaComm = {
isIn = function (self, compare)
for k, v in pairs(self) do
if v == comapre then
return true
end
end
return false
end,
}
local new = {}
for k,v in pairs(func) do
new[v] = metaComm[v]
end
setmetatable(metaTable, {__index = new})
return metaTable
end
local function betser(t, tTracker, tabs)
-- get type and store it
iType = type(t)
-- code to check if it is a recursion loop
local iTracker = tTracker
if iTracker:isIn(t) and iType == "table" then -- line 26
error("Cannot handle Recrsive loop")
elseif iType == "table" then
iTracker[#iTracker+1] = t
end
-- Ready tabs
local tab = ""
local tabM1 = ""
for i = 0, tabs, 1 do
tab = tab .. "\t\t"
if i ~= 0 then
tabM1 = tabM1 .. "\t\t"
end
end
-- begin serialization
if iType == "table" then
result = "{\n"
for k,v in pairs(t) do
result = result..tab.."[" .. betser(k, iTracker, (tabs+1)) .. "] = " .. betser(v, iTracker, (tabs+1)) .. ",\n"
end
result = result .. tabM1 .. "}"
return result
elseif iType == "string" then
return string.format("%q", t)
elseif iType == "number" or iType == "boolean" or iType == "nil" then
return tostring(t)
elseif iType == "function" then
return "**function**"
else
error("cannot serialize type " .. iType)
end
end
function serialize(t)
local nTracker = meta({"isIn"})
return betser(t, nTracker, 0)
end
-- test table for testing
test = {}
test.test = {}
test.test.beta = "test"
test.beta = "test"
test.aplha = test
--Print what is returned
print(serialize(test))