Fix itemdef defaults not being applied in async env

This commit is contained in:
sfan5 2023-06-24 17:58:43 +02:00
parent f6bddc4e8d
commit 43c9c38a28
3 changed files with 12 additions and 0 deletions

@ -36,11 +36,16 @@ do
setmetatable(v, {__newindex = {}})
-- Reassemble the other tables
if v.type == "node" then
getmetatable(v).__index = all.nodedef_default
all.registered_nodes[k] = v
elseif v.type == "craft" then
getmetatable(v).__index = all.craftitemdef_default
all.registered_craftitems[k] = v
elseif v.type == "tool" then
getmetatable(v).__index = all.tooldef_default
all.registered_tools[k] = v
else
getmetatable(v).__index = all.noneitemdef_default
end
end

@ -261,6 +261,11 @@ function core.get_globals_to_transfer()
local all = {
registered_items = copy_filtering(core.registered_items),
registered_aliases = core.registered_aliases,
nodedef_default = copy_filtering(core.nodedef_default),
craftitemdef_default = copy_filtering(core.craftitemdef_default),
tooldef_default = copy_filtering(core.tooldef_default),
noneitemdef_default = copy_filtering(core.noneitemdef_default),
}
return all
end

@ -19,6 +19,8 @@ local function do_tests()
-- alias handling
assert(core.registered_items["unittests:steel_ingot_alias"].name ==
"unittests:steel_ingot")
-- fallback to item defaults
assert(core.registered_items["unittests:description_test"].on_place == true)
end
function unittests.async_test()