combinator_description not accessible on ghosts

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
User avatar
Sharparam
Burner Inserter
Burner Inserter
Posts: 15
Joined: Sat Mar 25, 2023 11:21 pm
Contact:

combinator_description not accessible on ghosts

Post 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.
Viidi
Inserter
Inserter
Posts: 26
Joined: Thu Jun 16, 2022 8:52 pm
Contact:

Re: combinator_description not accessible on ghosts

Post by Viidi »

I support this request
Post Reply

Return to “Modding interface requests”