Merge pull request #70 from mamoniot/beta-localizedstring-entity-fix

Add fallback value in GUI sprite button tooltips for entity prototypes
This commit is contained in:
Monica Moniot
2023-04-30 14:26:31 -04:00
committed by GitHub
2 changed files with 12 additions and 12 deletions

View File

@@ -174,7 +174,7 @@ function inventory_tab.build(map_data, player_data)
tooltip = { "", tooltip = { "",
img_path, img_path,
" [font=default-semibold]", " [font=default-semibold]",
{ item_string }, item_string,
"[/font]\n"..format.number(count), "[/font]\n"..format.number(count),
}, },
} }
@@ -198,7 +198,7 @@ function inventory_tab.build(map_data, player_data)
tooltip = { "", tooltip = { "",
img_path, img_path,
" [font=default-semibold]", " [font=default-semibold]",
{ item_string }, item_string,
"[/font]\n"..format.number(count), "[/font]\n"..format.number(count),
}, },
} }
@@ -222,7 +222,7 @@ function inventory_tab.build(map_data, player_data)
tooltip = { "", tooltip = { "",
img_path, img_path,
" [font=default-semibold]", " [font=default-semibold]",
{ item_string }, item_string,
"[/font]\n"..format.number(count), "[/font]\n"..format.number(count),
}, },
} }

View File

@@ -35,23 +35,23 @@ end
--- Builds a valid sprite path or returns nil --- Builds a valid sprite path or returns nil
--- @param item string --- @param item string
--- @return string, string, string --- @return string, string, LocalizedString
function util.generate_item_references(item) function util.generate_item_references(item)
local sprite = nil local sprite = nil
local image_path = "" local image_path = ""
local item_name = "" local item_name
if game.is_valid_sprite_path("item/" .. item) then if game.is_valid_sprite_path("item/" .. item) then
sprite = "item/" .. item sprite = "item/" .. item
image_path = "[img=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 elseif game.is_valid_sprite_path("fluid/" .. item) then
sprite = "fluid/" .. item sprite = "fluid/" .. item
image_path = "[img=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 elseif game.is_valid_sprite_path("virtual-signal/" .. item) then
sprite = "virtual-signal/" .. item sprite = "virtual-signal/" .. item
image_path = "[img=virtual-signal." .. item .. "]" image_path = "[img=virtual-signal." .. item .. "]"
item_name = "virtual-signal." .. item item_name = {"?", { "virtual-signal." .. item }, "LocalizedString failure: " .. item }
end end
return sprite, image_path, item_name return sprite, image_path, item_name
end end
@@ -79,7 +79,7 @@ function util.slot_table_build_from_manifest(manifest, color)
tooltip = { tooltip = {
"", "",
img_path, img_path,
{ item_string }, item_string,
"\n"..format.number(count), "\n"..format.number(count),
}, },
} }
@@ -121,7 +121,7 @@ function util.slot_table_build_from_station(station)
tooltip = { tooltip = {
"", "",
img_path, img_path,
{ item_string }, item_string,
"\n"..format.number(count), "\n"..format.number(count),
}, },
number = count number = count
@@ -158,7 +158,7 @@ function util.slot_table_build_from_deliveries(station)
tooltip = { tooltip = {
"", "",
img_path, img_path,
{ item_string }, item_string,
"\n"..format.number(count), "\n"..format.number(count),
}, },
number = count number = count