Skip to content

Commit

Permalink
Support aliases in node name resolution. For example, `//set mapgen_d…
Browse files Browse the repository at this point in the history
…irt`. Technique outlined by kharl in IRC.
  • Loading branch information
Uberi committed Jun 24, 2013
1 parent 679388c commit bb6d734
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions worldedit_commands/init.lua
Expand Up @@ -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
Expand Down

0 comments on commit bb6d734

Please sign in to comment.