aboutsummaryrefslogtreecommitdiff
path: root/builtin
diff options
context:
space:
mode:
Diffstat (limited to 'builtin')
-rw-r--r--builtin/async/game.lua16
-rw-r--r--builtin/game/register.lua2
2 files changed, 16 insertions, 2 deletions
diff --git a/builtin/async/game.lua b/builtin/async/game.lua
index 8cb9720b6..6512f0706 100644
--- a/builtin/async/game.lua
+++ b/builtin/async/game.lua
@@ -25,11 +25,13 @@ do
local all = assert(core.transferred_globals)
core.transferred_globals = nil
- -- reassemble other tables
all.registered_nodes = {}
all.registered_craftitems = {}
all.registered_tools = {}
for k, v in pairs(all.registered_items) do
+ -- Disable further modification
+ setmetatable(v, {__newindex = {}})
+ -- Reassemble the other tables
if v.type == "node" then
all.registered_nodes[k] = v
elseif v.type == "craftitem" then
@@ -43,3 +45,15 @@ do
core[k] = v
end
end
+
+-- For tables that are indexed by item name:
+-- If table[X] does not exist, default to table[core.registered_aliases[X]]
+local alias_metatable = {
+ __index = function(t, name)
+ return rawget(t, core.registered_aliases[name])
+ end
+}
+setmetatable(core.registered_items, alias_metatable)
+setmetatable(core.registered_nodes, alias_metatable)
+setmetatable(core.registered_craftitems, alias_metatable)
+setmetatable(core.registered_tools, alias_metatable)
diff --git a/builtin/game/register.lua b/builtin/game/register.lua
index 0be107c36..ee4edabbf 100644
--- a/builtin/game/register.lua
+++ b/builtin/game/register.lua
@@ -1,4 +1,4 @@
--- Minetest: builtin/misc_register.lua
+-- Minetest: builtin/register.lua
local S = core.get_translator("__builtin")