Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit bb6d734

Browse files
committedJun 24, 2013
Support aliases in node name resolution. For example, //set mapgen_dirt. Technique outlined by kharl in IRC.
1 parent 679388c commit bb6d734

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed
 

Diff for: ‎worldedit_commands/init.lua

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,18 @@ end
1717

1818
--determines whether `nodename` is a valid node name, returning a boolean
1919
worldedit.normalize_nodename = function(nodename)
20-
if minetest.registered_nodes[nodename] then --directly found node name
21-
return nodename
22-
elseif minetest.registered_nodes["default:" .. nodename] then --found node name in default
23-
return "default:" .. nodename
20+
local fullname = ItemStack({name=nodename}):get_name() --resolve aliases of node names to full names
21+
if minetest.registered_nodes[fullname] then --directly found node name or alias of nodename
22+
return fullname
2423
end
2524
for key, value in pairs(minetest.registered_nodes) do
2625
if key:find(":" .. nodename, 1, true) then --found in mod
2726
return key
2827
end
2928
end
29+
nodename = nodename:lower() --lowercase both for case insensitive comparison
3030
for key, value in pairs(minetest.registered_nodes) do
31-
if value.description:lower() == nodename:lower() then --found in description
31+
if value.description:lower() == nodename then --found in description
3232
return key
3333
end
3434
end

0 commit comments

Comments
 (0)
Please sign in to comment.