Improve the method of getting the name and mod of nodes
This commit is contained in:
parent
ccb2dc8cc3
commit
90d22af968
9
init.lua
9
init.lua
@ -48,15 +48,12 @@ function get_looking_node(player)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function describe_node(node)
|
function describe_node(node)
|
||||||
local mod, nodename = string.match(node.name, "(.*):(.*)")
|
local mod, nodename = minetest.registered_nodes[node.name].mod_origin, minetest.registered_nodes[node.name].description
|
||||||
mod = mod or "?"
|
|
||||||
nodename = nodename or "?"
|
|
||||||
mod = remove_unneeded(capitalize(mod))
|
mod = remove_unneeded(capitalize(mod))
|
||||||
nodename = remove_unneeded(capitalize(nodename))
|
nodename = remove_unneeded(capitalize(nodename))
|
||||||
return
|
return
|
||||||
"Name: " .. nodename .. "\n" ..
|
"Name: " .. nodename .. "\n" ..
|
||||||
"Mod: " .. mod .. "\n"
|
"Mod: " .. mod .. "\n"
|
||||||
-- "Description: " .. node.description
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function remove_unneeded(str)
|
function remove_unneeded(str)
|
||||||
@ -64,5 +61,5 @@ function remove_unneeded(str)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function capitalize(str)
|
function capitalize(str)
|
||||||
return str:gsub("(%l)(%w+)", function(a,b) return string.upper(a)..b end)
|
return string.gsub(" "..str, "%W%l", string.upper):sub(2)
|
||||||
end
|
end
|
Loading…
x
Reference in New Issue
Block a user