diff options
author | ShadowNinja <shadowninja@minetest.net> | 2013-12-04 13:39:57 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2013-12-04 14:31:55 -0500 |
commit | 000da6b25de2af1cc517b9f3c5e9b3576625ec4c (patch) | |
tree | 6f0286e97b5ca7ae737a40e2b697f5fcaf95ae7a | |
parent | e51ad5337f78060557d63de6407a2c6bce071aba (diff) | |
download | minetest-000da6b25de2af1cc517b9f3c5e9b3576625ec4c.tar.gz minetest-000da6b25de2af1cc517b9f3c5e9b3576625ec4c.tar.bz2 minetest-000da6b25de2af1cc517b9f3c5e9b3576625ec4c.zip |
Only create one alias metatable
-rw-r--r-- | builtin/misc_register.lua | 20 |
1 files changed, 9 insertions, 11 deletions
diff --git a/builtin/misc_register.lua b/builtin/misc_register.lua index aa062d731..54022a361 100644 --- a/builtin/misc_register.lua +++ b/builtin/misc_register.lua @@ -24,17 +24,15 @@ minetest.registered_aliases = {} -- For tables that are indexed by item name: -- If table[X] does not exist, default to table[minetest.registered_aliases[X]] -local function set_alias_metatable(table) - setmetatable(table, { - __index = function(name) - return rawget(table, minetest.registered_aliases[name]) - end - }) -end -set_alias_metatable(minetest.registered_items) -set_alias_metatable(minetest.registered_nodes) -set_alias_metatable(minetest.registered_craftitems) -set_alias_metatable(minetest.registered_tools) +local alias_metatable = { + __index = function(t, name) + return rawget(t, minetest.registered_aliases[name]) + end +} +setmetatable(minetest.registered_items, alias_metatable) +setmetatable(minetest.registered_nodes, alias_metatable) +setmetatable(minetest.registered_craftitems, alias_metatable) +setmetatable(minetest.registered_tools, alias_metatable) -- These item names may not be used because they would interfere -- with legacy itemstrings |