Page 1 of 1

combinator_description not accessible on ghosts

Posted: Wed Nov 06, 2024 7:02 pm
by Sharparam
Trying to access the combinator_description field on a LuaEntity that is a ghost of a combinator entity fails with the following error:

Code: Select all

Entity is not arithmetic-combinator or decider-combinator or constant-combinator.
However, the base game is somehow able to set the description on combinators while they are ghosts, and then they persist when they are built (the description even shows in the tooltip while they are ghosts).

Is there some bug with the field? Or how is the base game able to set the description but mods get an error?

If it's not a bug, this is a request to be able to use the description property while the entity is a ghost, just like the base game can.

Edit: For anyone needing a workaround in the meanwhile, this is what I did:

When accessing description, use custom helper functions that check if the entity is a ghost:

Code: Select all

function set_description(entity, description)
  if entity.name == "entity-ghost" then
    if entity.tags then
      local tags = entity.tags
      tags.description = description
      entity.tags = tags
    else
      entity.tags = { description = description }
    end
  else
    entity.combinator_description = description
  end
end

function get_description(entity)
  if entity.name == "entity-ghost" then
    return entity.tags and entity.tags.description or ""
  end
  return entity.combinator_description
end
Then, when the entity is actually built you have to transfer the description from the tags into the actual description field.

Re: combinator_description not accessible on ghosts

Posted: Thu Nov 07, 2024 3:15 pm
by Viidi
I support this request