From dbee1ab2dc31aaf8299313aeee52b8cbaf4b1916 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Fri, 3 Feb 2017 02:10:10 +0100 Subject: Fix crash for tools w/o uses or maxlevel defined --- init.lua | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/init.lua b/init.lua index c243380..bbe79d0 100644 --- a/init.lua +++ b/init.lua @@ -965,18 +965,24 @@ doc.add_category("tools", { local group = nil local mintime = nil local groupcount = 0 - local uses = nil + local realuses = nil for k,v in pairs(gc) do local maxlevel = v.maxlevel if maxlevel == nil then + -- Default from tool.h maxlevel = 1 end if groupcount == 0 then group = k - uses = v.uses * math.pow(3, v.maxlevel) + local uses = v.uses + if v.uses == nil then + -- Default from tool.h + uses = 20 + end + realuses = uses * math.pow(3, maxlevel) end for rating, time in pairs(v.times) do - local realtime = time / v.maxlevel + local realtime = time / maxlevel if mintime == nil or realtime < mintime then mintime = realtime end @@ -989,8 +995,8 @@ doc.add_category("tools", { comp[e].count = groupcount comp[e].group = group comp[e].mintime = mintime - if uses ~= nil then - comp[e].uses = uses + if realuses ~= nil then + comp[e].uses = realuses elseif type(entries[e].data.def._doc_items_durability) == "number" then comp[e].uses = entries[e].data.def._doc_items_durability else -- cgit v1.2.3