1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-02 16:38:41 +00:00
This commit is contained in:
y5nw 2025-02-22 21:47:00 +01:00
parent e713d5291d
commit 738b3cfadc

View file

@ -31,24 +31,26 @@ local function prepare_objects(value)
if type_ == "boolean" or type_ == "number" then
return
end
local count = counts[val]
if not recount then
local count = counts[val]
counts[val] = (count or 0) + 1
end
local mt = (not recount) and (type_ == "table" or type_ == "userdata") and getmetatable(val)
local mt = (not count) and (type_ == "table" or type_ == "userdata") and getmetatable(val)
if mt and core.known_metatables[mt] then
type_lookup[val] = core.known_metatables[mt]
count_values(val, true)
elseif type_ == "table" then
for k, v in pairs(val) do
count_values(k)
count_values(v)
if recount or not count then
for k, v in pairs(val) do
count_values(k)
count_values(v)
end
end
elseif type_ ~= "string" then
elseif type_ ~= "string" and type_ ~= "function" then
error("unsupported type: " .. type_)
end
end
count_values(value, false)
count_values(value)
return counts, type_lookup
end