Some fixes

This commit is contained in:
Jean-Patrick Guerrero 2020-07-15 02:05:33 +02:00
parent 3a0a2c032d
commit bfa7f4d631

@ -698,9 +698,6 @@ local function cache_drops(name, drop)
end end
local function cache_recipes(item) local function cache_recipes(item)
item = reg_aliases[item] or item
local def = reg_items[item]
if not def then return end
recipes_cache[item] = get_all_recipes(item) recipes_cache[item] = get_all_recipes(item)
end end
@ -782,8 +779,16 @@ local function is_fav(favs, query_item)
return fav, i return fav, i
end end
local function str_newline(str) local function weird_desc(str)
return find(str, "\n") return not true_str(str) or find(str, "\n") or not find(str, "%u")
end
local function toupper(str)
return str:gsub("%f[%w]%l", upper):gsub("_", " ")
end
local function strip_newline(str)
return match(str, "[^\n]*")
end end
local function get_desc(item, lang_code) local function get_desc(item, lang_code)
@ -794,10 +799,15 @@ local function get_desc(item, lang_code)
local def = reg_items[item] local def = reg_items[item]
if def then if def then
if true_str(def.description) then local desc = def.description
return match(translate(lang_code, def.description), "[^\n]*") if true_str(desc) then
if not find(desc, "%u") then
return strip_newline(toupper(desc))
end
return strip_newline(translate(lang_code, desc))
elseif true_str(item) then elseif true_str(item) then
return match(item, ":.*"):gsub("%W%l", upper):sub(2):gsub("_", " ") return toupper(match(item, ":(.*)"))
end end
end end
@ -933,12 +943,12 @@ local function get_output_fs(lang_code, fs, rcp, shapeless, right, btn_size, _bt
local def = reg_items[name] local def = reg_items[name]
local unknown = not def or nil local unknown = not def or nil
local weird_desc = name ~= "" and def and local desc = def and def.description
(not true_str(def.description) or str_newline(def.description)) or nil local weird = name ~= "" and desc and weird_desc(desc) or nil
local infos = { local infos = {
unknown = unknown, unknown = unknown,
weird_desc = weird_desc, weird = weird,
burntime = fuel_cache[name], burntime = fuel_cache[name],
repair = repairable(name), repair = repairable(name),
rarity = rcp.rarity, rarity = rcp.rarity,
@ -1058,12 +1068,12 @@ local function get_grid_fs(lang_code, fs, rcp, spacing)
local def = reg_items[name] local def = reg_items[name]
local unknown = not def or nil local unknown = not def or nil
unknown = not groups and unknown or nil unknown = not groups and unknown or nil
local weird_desc = name ~= "" and def and local desc = def and def.description
(not true_str(def.description) or str_newline(def.description)) or nil local weird = name ~= "" and desc and weird_desc(desc) or nil
local infos = { local infos = {
unknown = unknown, unknown = unknown,
weird_desc = weird_desc, weird = weird,
groups = groups, groups = groups,
burntime = fuel_cache[name], burntime = fuel_cache[name],
cooktime = cooktime, cooktime = cooktime,