diff options
author | Wuzzy <almikes@aol.com> | 2016-08-01 06:44:38 +0200 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2016-08-01 06:44:38 +0200 |
commit | 87c73a5a19c182ae0ea205386feb877899ab10e6 (patch) | |
tree | 4dcb48726721a6bd4ca21585be2d9a4ea3a0554f | |
parent | 0c0b1ccdb4158fbef101f9433b5ae8a51f2c87d8 (diff) |
Expose rating and level in tool info
-rw-r--r-- | init.lua | 29 |
1 files changed, 25 insertions, 4 deletions
@@ -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" |