When a table is returned from a function, if the function is called from another object thanks to https://api.tabletopsimulator.com/object/#call , then metatable data are missing from the returned table
to reproduce :
in Global script :
function getTableWithMeta()
return setmetatable({"foo","bar"},{__index = function() return "unknown key" end})
end
function onLoad()
local tt = getTableWithMeta()
print(logString(tt))
print(logString(getmetatable(tt)))
print(tt.foo)
endoutput =
1: foo
2: bar
“__index”: <func>
unknown key
in any object script :
function onLoad(save_state)
local tt = Global.call("getTableWithMeta", {})
print(logString(tt))
print(logString(getmetatable(tt)))
print(tt.foo)
endoutput =
1: foo
2: bar
nil
nil