mirror of
https://github.com/Uberi/Minetest-WorldEdit.git
synced 2024-12-25 18:20:38 +01:00
Support aliases in node name resolution. For example, //set mapgen_dirt
. Technique outlined by kharl in IRC.
This commit is contained in:
parent
9db6192eba
commit
48009b6c62
@ -17,18 +17,18 @@ end
|
|||||||
|
|
||||||
--determines whether `nodename` is a valid node name, returning a boolean
|
--determines whether `nodename` is a valid node name, returning a boolean
|
||||||
worldedit.normalize_nodename = function(nodename)
|
worldedit.normalize_nodename = function(nodename)
|
||||||
if minetest.registered_nodes[nodename] then --directly found node name
|
local fullname = ItemStack({name=nodename}):get_name() --resolve aliases of node names to full names
|
||||||
return nodename
|
if minetest.registered_nodes[fullname] then --directly found node name or alias of nodename
|
||||||
elseif minetest.registered_nodes["default:" .. nodename] then --found node name in default
|
return fullname
|
||||||
return "default:" .. nodename
|
|
||||||
end
|
end
|
||||||
for key, value in pairs(minetest.registered_nodes) do
|
for key, value in pairs(minetest.registered_nodes) do
|
||||||
if key:find(":" .. nodename, 1, true) then --found in mod
|
if key:find(":" .. nodename, 1, true) then --found in mod
|
||||||
return key
|
return key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
nodename = nodename:lower() --lowercase both for case insensitive comparison
|
||||||
for key, value in pairs(minetest.registered_nodes) do
|
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
|
return key
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user