From 704acf38506fafdb75da0492ebf051b275a1f09f Mon Sep 17 00:00:00 2001 From: Will Berry <73126355+wdberry@users.noreply.github.com> Date: Tue, 4 Apr 2023 11:53:23 -0400 Subject: [PATCH] Add fallback value in GUI sprite button tooltips for entity prototypes --- cybersyn/scripts/gui/inventory.lua | 6 +++--- cybersyn/scripts/gui/util.lua | 18 +++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/cybersyn/scripts/gui/inventory.lua b/cybersyn/scripts/gui/inventory.lua index 14b55da..20405d9 100644 --- a/cybersyn/scripts/gui/inventory.lua +++ b/cybersyn/scripts/gui/inventory.lua @@ -174,7 +174,7 @@ function inventory_tab.build(map_data, player_data) tooltip = { "", img_path, " [font=default-semibold]", - { item_string }, + item_string, "[/font]\n"..format.number(count), }, } @@ -198,7 +198,7 @@ function inventory_tab.build(map_data, player_data) tooltip = { "", img_path, " [font=default-semibold]", - { item_string }, + item_string, "[/font]\n"..format.number(count), }, } @@ -222,7 +222,7 @@ function inventory_tab.build(map_data, player_data) tooltip = { "", img_path, " [font=default-semibold]", - { item_string }, + item_string, "[/font]\n"..format.number(count), }, } diff --git a/cybersyn/scripts/gui/util.lua b/cybersyn/scripts/gui/util.lua index 6d2bbd8..dd7c7f6 100644 --- a/cybersyn/scripts/gui/util.lua +++ b/cybersyn/scripts/gui/util.lua @@ -35,23 +35,23 @@ end --- Builds a valid sprite path or returns nil --- @param item string ---- @return string, string, string +--- @return string, string, LocalizedString function util.generate_item_references(item) local sprite = nil local image_path = "" - local item_name = "" + local item_name if game.is_valid_sprite_path("item/" .. item) then sprite = "item/" .. item image_path = "[img=item." .. item .. "]" - item_name = "item-name." .. item + item_name = {"?", { "item-name." .. item }, { "entity-name." .. item }, "LocalizedString failure: " .. item } elseif game.is_valid_sprite_path("fluid/" .. item) then sprite = "fluid/" .. item image_path = "[img=fluid." .. item .. "]" - item_name = "fluid-name." .. item + item_name = {"?", { "fluid-name." .. item }, "LocalizedString failure: " .. item } elseif game.is_valid_sprite_path("virtual-signal/" .. item) then sprite = "virtual-signal/" .. item image_path = "[img=virtual-signal." .. item .. "]" - item_name = "virtual-signal." .. item + item_name = {"?", { "virtual-signal." .. item }, "LocalizedString failure: " .. item } end return sprite, image_path, item_name end @@ -78,8 +78,8 @@ function util.slot_table_build_from_manifest(manifest, color) number = count, tooltip = { "", - img_path, - { item_string }, + img_path, + item_string, "\n"..format.number(count), }, } @@ -121,7 +121,7 @@ function util.slot_table_build_from_station(station) tooltip = { "", img_path, - { item_string }, + item_string, "\n"..format.number(count), }, number = count @@ -158,7 +158,7 @@ function util.slot_table_build_from_deliveries(station) tooltip = { "", img_path, - { item_string }, + item_string, "\n"..format.number(count), }, number = count