minetest/builtin/common/metatable.lua
y5nw fc80f65a6d
Try to preserve metatable when exchanging data with the async env (#14369)
Co-authored-by: sfan5 <sfan5@live.de>
Co-authored-by: Lars Mueller <appgurulars@gmx.de>
2024-03-06 18:04:49 +01:00

14 lines
616 B
Lua

-- Registered metatables, used by the C++ packer
local known_metatables = {}
function core.register_async_metatable(name, mt)
assert(type(name) == "string", ("attempt to use %s value as metatable name"):format(type(name)))
assert(type(mt) == "table", ("attempt to register a %s value as metatable"):format(type(mt)))
assert(known_metatables[name] == nil or known_metatables[name] == mt,
("attempt to override metatable %s"):format(name))
known_metatables[name] = mt
known_metatables[mt] = name
end
core.known_metatables = known_metatables
core.register_async_metatable("__builtin:vector", vector.metatable)