summaryrefslogtreecommitdiff
path: root/worldedit_commands
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2013-06-24 17:13:10 -0400
committerAnthony Zhang <azhang9@gmail.com>2013-06-24 17:13:10 -0400
commit48009b6c62902af784817b9539d108059227533b (patch)
tree4a6bc3f0a2a4ed7dfe6ac744177683680f5851d2 /worldedit_commands
parent9db6192ebaff75d1cdefd1f49c7fbab07fa86648 (diff)
Support aliases in node name resolution. For example, `//set mapgen_dirt`. Technique outlined by kharl in IRC.
Diffstat (limited to 'worldedit_commands')
-rw-r--r--worldedit_commands/init.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/worldedit_commands/init.lua b/worldedit_commands/init.lua
index d98dc9d..d75fdbf 100644
--- a/worldedit_commands/init.lua
+++ b/worldedit_commands/init.lua
@@ -17,18 +17,18 @@ end
--determines whether `nodename` is a valid node name, returning a boolean
worldedit.normalize_nodename = function(nodename)
- if minetest.registered_nodes[nodename] then --directly found node name
- return nodename
- elseif minetest.registered_nodes["default:" .. nodename] then --found node name in default
- return "default:" .. nodename
+ local fullname = ItemStack({name=nodename}):get_name() --resolve aliases of node names to full names
+ if minetest.registered_nodes[fullname] then --directly found node name or alias of nodename
+ return fullname
end
for key, value in pairs(minetest.registered_nodes) do
if key:find(":" .. nodename, 1, true) then --found in mod
return key
end
end
+ nodename = nodename:lower() --lowercase both for case insensitive comparison
for key, value in pairs(minetest.registered_nodes) do
- if value.description:lower() == nodename:lower() then --found in description
+ if value.description:lower() == nodename then --found in description
return key
end
end