summaryrefslogtreecommitdiff
path: root/init.lua
diff options
context:
space:
mode:
authorWuzzy <almikes@aol.com>2016-12-14 13:14:25 +0100
committerWuzzy <almikes@aol.com>2016-12-14 13:14:25 +0100
commit24db5de70f51223cc587a306085e599031b0677d (patch)
tree4787f78906894d22b0cd2ad208790f359d7e5e2b /init.lua
parent4cfdf07c14d769281e69ecba549471465f67f94b (diff)
Attempt to reasonably display mining times
Diffstat (limited to 'init.lua')
-rw-r--r--init.lua35
1 files changed, 34 insertions, 1 deletions
diff --git a/init.lua b/init.lua
index 1f67fa3..e6f2572 100644
--- a/init.lua
+++ b/init.lua
@@ -165,8 +165,10 @@ local toolcaps_to_text = function(tool_capabilities, check_uses)
local groupcaps = tool_capabilities.groupcaps
if groupcaps ~= nil then
local miningcapstr = ""
+ local miningtimesstr = ""
local miningusesstr = ""
local caplines = 0
+ local timelines = 0
local useslines = 0
for k,v in pairs(groupcaps) do
-- Mining capabilities
@@ -199,6 +201,33 @@ local toolcaps_to_text = function(tool_capabilities, check_uses)
miningcapstr = miningcapstr .. "\n"
caplines = caplines + 1
+ for rating=3, 1, -1 do
+ if v.times ~= nil and v.times[rating] ~= nil then
+ local maxtime = v.times[rating]
+ local mintime
+ local mintimestr, maxtimestr
+ if v.maxlevel then
+ mintime = maxtime / v.maxlevel
+ else
+ mintime = maxtime
+ end
+ mintimestr = string.format("%.1f", mintime)
+ maxtimestr = string.format("%.1f", maxtime)
+ if mintimestr ~= maxtimestr then
+ miningtimesstr = miningtimesstr ..
+ S("• @1, rating @2: @3s-@4s",
+ doc.sub.items.get_group_name(k), rating,
+ mintimestr, maxtimestr)
+ else
+ S("• @1, rating @2: @3s",
+ doc.sub.items.get_group_name(k), rating,
+ mintimestr)
+ end
+ miningtimesstr = miningtimesstr.. "\n"
+ timelines = timelines + 1
+ end
+ end
+
-- Number of mining uses
if check_uses and v.maxlevel ~= nil and v.uses ~= nil and v.uses > 0 then
for level=0, v.maxlevel do
@@ -214,11 +243,15 @@ local toolcaps_to_text = function(tool_capabilities, check_uses)
formstring = formstring .. miningcapstr
formstring = newline(formstring)
end
+ if timelines > 0 then
+ formstring = formstring .. S("Mining times:") .. "\n"
+ formstring = formstring .. miningtimesstr
+ end
if useslines > 0 then
formstring = formstring .. S("Mining durability:") .. "\n"
formstring = formstring .. miningusesstr
end
- if caplines > 0 or useslines > 0 then
+ if caplines > 0 or useslines > 0 or timelines > 0 then
formstring = newline2(formstring)
end
end