Fix nil item crash in get_tooltip() - Fixes #84, regression caused by d950c71db (@pauloue)

This commit is contained in:
Jean-Patrick Guerrero 2019-06-30 16:24:18 +02:00
parent e710fcd483
commit ca18ae0e3a
1 changed files with 8 additions and 4 deletions

View File

@ -30,9 +30,9 @@ local maxn, sort, concat, insert, copy =
table.maxn, table.sort, table.concat, table.insert,
table.copy
local fmt, find, gmatch, match, sub, split, lower =
local fmt, find, gmatch, match, sub, split, upper, lower =
string.format, string.find, string.gmatch, string.match,
string.sub, string.split, string.lower
string.sub, string.split, string.upper, string.lower
local min, max, floor, ceil = math.min, math.max, math.floor, math.ceil
local pairs, next, unpack = pairs, next, unpack
@ -414,7 +414,11 @@ local function get_tooltip(item, groups, cooktime, burntime)
groupstr = concat(groupstr, ", ")
tooltip = S("Any item belonging to the group(s): @1", groupstr)
else
tooltip = reg_items[item].description
local def = reg_items[item]
tooltip = def and def.description or
(def and match(item, ":.*"):gsub("%W%l", upper):sub(2):gsub("_", " ") or
S("Unknown Item (@1)", item))
end
if cooktime then
@ -734,7 +738,7 @@ local function search(data)
local filters = {}
if search_filter then
for filter_name, values in gmatch(filter, sub(extras, 6, -1)) do
for filter_name, values in gmatch(filter, sub(extras, 6)) do
if search_filters[filter_name] then
values = split(values, ",")
filters[filter_name] = values