From 90d22af96873fc818ef33132be84b99e8575523c Mon Sep 17 00:00:00 2001 From: mightyalex200 Date: Sun, 30 Jul 2017 15:55:38 -0400 Subject: [PATCH] Improve the method of getting the name and mod of nodes --- init.lua | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/init.lua b/init.lua index f37f094..3e74f16 100644 --- a/init.lua +++ b/init.lua @@ -48,15 +48,12 @@ function get_looking_node(player) end function describe_node(node) - local mod, nodename = string.match(node.name, "(.*):(.*)") - mod = mod or "?" - nodename = nodename or "?" + local mod, nodename = minetest.registered_nodes[node.name].mod_origin, minetest.registered_nodes[node.name].description mod = remove_unneeded(capitalize(mod)) nodename = remove_unneeded(capitalize(nodename)) return "Name: " .. nodename .. "\n" .. - "Mod: " .. mod .. "\n" - -- "Description: " .. node.description + "Mod: " .. mod .. "\n" end function remove_unneeded(str) @@ -64,5 +61,5 @@ function remove_unneeded(str) end 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 \ No newline at end of file