Fix crash for tools w/o uses or maxlevel defined
This commit is contained in:
parent
b7cadfd37e
commit
dbee1ab2dc
16
init.lua
16
init.lua
@ -965,18 +965,24 @@ doc.add_category("tools", {
|
|||||||
local group = nil
|
local group = nil
|
||||||
local mintime = nil
|
local mintime = nil
|
||||||
local groupcount = 0
|
local groupcount = 0
|
||||||
local uses = nil
|
local realuses = nil
|
||||||
for k,v in pairs(gc) do
|
for k,v in pairs(gc) do
|
||||||
local maxlevel = v.maxlevel
|
local maxlevel = v.maxlevel
|
||||||
if maxlevel == nil then
|
if maxlevel == nil then
|
||||||
|
-- Default from tool.h
|
||||||
maxlevel = 1
|
maxlevel = 1
|
||||||
end
|
end
|
||||||
if groupcount == 0 then
|
if groupcount == 0 then
|
||||||
group = k
|
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
|
end
|
||||||
for rating, time in pairs(v.times) do
|
for rating, time in pairs(v.times) do
|
||||||
local realtime = time / v.maxlevel
|
local realtime = time / maxlevel
|
||||||
if mintime == nil or realtime < mintime then
|
if mintime == nil or realtime < mintime then
|
||||||
mintime = realtime
|
mintime = realtime
|
||||||
end
|
end
|
||||||
@ -989,8 +995,8 @@ doc.add_category("tools", {
|
|||||||
comp[e].count = groupcount
|
comp[e].count = groupcount
|
||||||
comp[e].group = group
|
comp[e].group = group
|
||||||
comp[e].mintime = mintime
|
comp[e].mintime = mintime
|
||||||
if uses ~= nil then
|
if realuses ~= nil then
|
||||||
comp[e].uses = uses
|
comp[e].uses = realuses
|
||||||
elseif type(entries[e].data.def._doc_items_durability) == "number" then
|
elseif type(entries[e].data.def._doc_items_durability) == "number" then
|
||||||
comp[e].uses = entries[e].data.def._doc_items_durability
|
comp[e].uses = entries[e].data.def._doc_items_durability
|
||||||
else
|
else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user