diff options
author | Wuzzy <almikes@aol.com> | 2017-02-03 02:19:34 +0100 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2017-02-03 02:19:34 +0100 |
commit | 284cc37a1fb8ea3b0252239e113f6209cd995c44 (patch) | |
tree | 8d99cd9e62db6cb3fdeb51e6f8784b6cae5f5dad | |
parent | dbee1ab2dc31aaf8299313aeee52b8cbaf4b1916 (diff) |
Make mod more stable with weird tool definitions
-rw-r--r-- | init.lua | 29 |
1 files changed, 19 insertions, 10 deletions
@@ -165,13 +165,18 @@ local factoid_toolcaps = function(tool_capabilities, check_uses) for k,v in pairs(groupcaps) do -- Mining capabilities 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 + if v.times then + 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 + else + minrating = 1 + maxrating = 1 end local maxlevel = v.maxlevel if not maxlevel then @@ -981,11 +986,15 @@ doc.add_category("tools", { end realuses = uses * math.pow(3, maxlevel) end - for rating, time in pairs(v.times) do - local realtime = time / maxlevel - if mintime == nil or realtime < mintime then - mintime = realtime + if v.times then + for rating, time in pairs(v.times) do + local realtime = time / maxlevel + if mintime == nil or realtime < mintime then + mintime = realtime + end end + else + mintime = 0 end if groups[k] ~= true then groupcount = groupcount + 1 |