diff options
author | Wuzzy <almikes@aol.com> | 2017-02-03 02:10:10 +0100 |
---|---|---|
committer | Wuzzy <almikes@aol.com> | 2017-02-03 02:10:10 +0100 |
commit | dbee1ab2dc31aaf8299313aeee52b8cbaf4b1916 (patch) | |
tree | 118267a56cb673d8d9ab26b95abecfc4b99ca6cd | |
parent | b7cadfd37e2220e839abc572852ed3fb11dd0d40 (diff) |
Fix crash for tools w/o uses or maxlevel defined
-rw-r--r-- | init.lua | 16 |
1 files changed, 11 insertions, 5 deletions
@@ -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 |