1
0
mirror of https://github.com/Uberi/Minetest-WorldEdit.git synced 2024-12-25 18:20:38 +01:00

Improve nodename normalization in some cases

This commit is contained in:
sfan5 2019-12-19 16:58:24 +01:00
parent abdecd4239
commit 974dcaa918

View File

@ -162,18 +162,18 @@ worldedit.normalize_nodename = function(nodename)
if minetest.registered_nodes[fullname] or fullname == "air" then -- full name if minetest.registered_nodes[fullname] or fullname == "air" then -- full name
return fullname return fullname
end end
nodename = nodename:lower()
for key, value in pairs(minetest.registered_nodes) do for key, value in pairs(minetest.registered_nodes) do
if string_endswith(key, ":" .. nodename) then -- matches name (w/o mod part) if string_endswith(key, ":" .. nodename) then -- matches name (w/o mod part)
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
local desc = strip_translation_escapes(value.description):lower() local desc = strip_translation_escapes(value.description):lower()
if desc == nodename then -- matches description if desc == nodename then -- matches description
return key return key
end end
if string_endswith(desc, " block") and desc == nodename.." block" then if desc == nodename .. " block" then
-- fuzzy description match (e.g. "Steel" == "Steel Block") -- fuzzy description match (e.g. "Steel" == "Steel Block")
return key return key
end end