From 83d183583b55f0cc47267773f0748e68ca72cb9b Mon Sep 17 00:00:00 2001 From: Austin Hicks Date: Mon, 25 Nov 2024 18:02:02 -0800 Subject: [PATCH] fa-info: fix: properly announce ghosts as entity ghost of x --- scripts/fa-info.lua | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/scripts/fa-info.lua b/scripts/fa-info.lua index b99e3209..20bb5008 100644 --- a/scripts/fa-info.lua +++ b/scripts/fa-info.lua @@ -123,7 +123,7 @@ local function ent_info_facing(ctx) if (ent.prototype.is_building and ent.supports_direction) - or (ent.name == "entity-ghost" and ent.ghost_prototype.is_building and ent.ghost_prototype.supports_direction) + or (ent.type == "entity-ghost" and ent.ghost_prototype.is_building and ent.ghost_prototype.supports_direction) then effective_direction = FaUtils.direction_lookup(ent.direction) if ent.type == "generator" then @@ -293,18 +293,6 @@ local function ent_info_resource(ctx) end end ----@param ctx fa.Info.EntInfoContext -local function ent_info_ghost(ctx) - local ent = ctx.ent - if ent.name == "entity-ghost" then - ctx.message:fragment({ - "fa.ent-info-ghost", - Localising.get_localised_name_with_fallback(ent.ghost_prototype), - Localising.get_localised_name_with_fallback(ent.prototype), - }) - end -end - ---@param ctx fa.Info.EntInfoContext local function ent_info_rail(ctx) local ent = ctx.ent @@ -1006,8 +994,17 @@ function mod.ent_info(pindex, ent, is_scanner) cursor_pos = { x = players[pindex].cursor_pos.x, y = players[pindex].cursor_pos.y }, } - ctx.message:fragment(Localising.get_localised_name_with_fallback(ent)) - + -- We need to special case ghosts, so that we can fold the "x of y" in, e.g. + -- "entity ghost of transport belt". + if ent.type == "entity-ghost" or ent.type == "tile-ghost" then + ctx.message:fragment({ + "fa.ent-info-ghost", + Localising.get_localised_name_with_fallback(ent), + Localising.get_localised_name_with_fallback(ent.ghost_prototype), + }) + else + ctx.message:fragment(Localising.get_localised_name_with_fallback(ent)) + end local function run_handler(handler, nolist) handler(ctx) if not nolist then ctx.message:list_item() end @@ -1038,7 +1035,6 @@ function mod.ent_info(pindex, ent, is_scanner) run_handler(ent_info_pole_neighbors, true) run_handler(ent_info_resource) - run_handler(ent_info_ghost) run_handler(ent_info_rail) run_handler(ent_info_character) run_handler(ent_info_character_corpse)