From 12e35f80f0e3db17505d62af64ea1f895cedb23c Mon Sep 17 00:00:00 2001 From: Jean-Patrick Guerrero Date: Mon, 9 Sep 2019 19:29:36 +0200 Subject: [PATCH] Fix replace tooltip --- init.lua | 16 ++++++++++------ locale/craftguide.fr.tr | 2 +- locale/template | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/init.lua b/init.lua index 9487b2a..9d28a31 100644 --- a/init.lua +++ b/init.lua @@ -406,6 +406,12 @@ local function groups_to_items(groups, get_all) return #names > 0 and concat(names, ",") or "" end +local function get_description(item, def) + return def and def.description or + (def and match(item, ":.*"):gsub("%W%l", upper):sub(2):gsub("_", " ") or + S("Unknown Item (@1)", item)) +end + local function get_tooltip(item, burntime, groups, cooktime, replace) local tooltip @@ -421,10 +427,7 @@ local function get_tooltip(item, burntime, groups, cooktime, replace) tooltip = S("Any item belonging to the group(s): @1", groupstr) else 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)) + tooltip = get_description(item, def) end if cooktime then @@ -440,7 +443,8 @@ local function get_tooltip(item, burntime, groups, cooktime, replace) if replace then local def = reg_items[replace] tooltip = tooltip .. "\n" .. - S("Replaced by: @1", colorize("yellow", def.description)) + S("Replaced by @1 on crafting", + colorize("yellow", get_description(replace, def))) end return fmt("tooltip[%s;%s]", item, ESC(tooltip)) @@ -531,7 +535,7 @@ local function get_recipe_fs(data) local burntime = fuel_cache[item] and fuel_cache[item].burntime - if groups or cooktime or burntime then + if groups or cooktime or burntime or replace then fs[#fs + 1] = get_tooltip(item, burntime, groups, cooktime, replace) end end diff --git a/locale/craftguide.fr.tr b/locale/craftguide.fr.tr index 00d502b..9aedeaf 100644 --- a/locale/craftguide.fr.tr +++ b/locale/craftguide.fr.tr @@ -6,7 +6,7 @@ Usage @1 of @2=Usage @1 de @2 Recipe @1 of @2=Recette @1 de @2 Burning time: @1=Temps de combustion : @1 Cooking time: @1=Temps de cuisson : @1 -Replaced by: @1=Remplacé par : @1 +Replaced by @1 on crafting=Remplacé par @1 lors de la fabrication Any item belonging to the group(s): @1=Tout item appartenant au(x) groupe(s) : @1 Recipe's too big to be displayed (@1x@2)=La recette est trop grande pour être affichée (@1x@2) Shapeless=Sans forme diff --git a/locale/template b/locale/template index 23b690e..514d129 100644 --- a/locale/template +++ b/locale/template @@ -7,7 +7,7 @@ Usage @1 of @2= Recipe @1 of @2= Burning time: @1= Cooking time: @1= -Replaced by: @1= +Replaced by @1 on crafting= Any item belonging to the group(s): @1= Recipe's too big to be displayed (@1x@2)= Shapeless=