From 87c73a5a19c182ae0ea205386feb877899ab10e6 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 1 Aug 2016 06:44:38 +0200 Subject: Expose rating and level in tool info --- init.lua | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'init.lua') diff --git a/init.lua b/init.lua index 560fa43..75817b1 100644 --- a/init.lua +++ b/init.lua @@ -112,11 +112,32 @@ local toolcaps_to_text = function(tool_capabilities) if groupcaps ~= nil then formstring = formstring .. "Mining capabilities:\n" for k,v in pairs(groupcaps) do - local levelstring = "" - if v.maxlevel ~= nil then - levelstring = ": Level "..v.maxlevel + local minrating, maxrating + for rating, time in pairs(v.times) do + if minrating == nil then minrating = rating else + if minrating > rating then minrating = rating end + end + if maxrating == nil then maxrating = rating else + if maxrating < rating then maxrating = rating end + end + end + local ratingstring = "Unknown rating" + if minrating ~= nil and maxrating ~= nil then + if minrating == maxrating then + ratingstring = "Rating "..minrating + else + ratingstring = "Rating "..minrating.."-"..maxrating + end + end + local levelstring + if v.maxlevel == 0 then + levelstring = "level 0" + elseif v.maxlevel ~= nil then + levelstring = "level 0-"..v.maxlevel + else + levelstring = "any level" end - formstring = formstring .. "- " .. group_to_string(k, "mining") .. levelstring .. "\n" + formstring = formstring .. "- " .. group_to_string(k, "mining") .. ": "..ratingstring..", ".. levelstring .. "\n" end end formstring = formstring .. "\n" -- cgit v1.2.3