Page 1 of 1
[2.0.54] LuaEntity.operable = false does not work on Ghosts in remote view
Posted: Sun Jun 01, 2025 3:06 pm
by Loup&Snoop
This wind turbine is "electric-energy-interface" with gui_mode = "none" by default.

- 06-01-2025, 10-51-24.png (525.21 KiB) Viewed 372 times
Bug #1) ElectricEnergyInterface.gui_mode = "none" gives no simulation, while a window still opens.
Expectation: "none" => no window at all OR window with just a simulation.
Bug #2) When built, call LuaEntity.operable = false. This should make it impossible to open that useless UI by clicking on the entity:
- If in character, real entity: UI no open

- If in character, ghost entity: UI no open

- If in remote view, real entity: UI no open

- If in remote view, ghost entity: UI DOES open when clicking on the entity.

My initial code is from planet Rubia (
https://mods.factorio.com/mod/rubia , version 0.69.47) in wind-turbine-control.lua.
Re: [2.0.54] LuaEntity.operable = false does not work on Ghosts in remote view
Posted: Mon Jun 02, 2025 1:10 am
by boskid
Uh, this looks like a hive of bugs and implementation details.
First layer of complexity here is that "operable" flag exists on each entity. When entity is a ghost, there are 2 entities involved: the shapeless "entity ghost" which is what exists on the surface, and the inner entity that is being represented by the ghost. When you write LuaEntity::operable = false, this sets this flag on the entity ghost, not on the inner entity. This already creates some problems.
Second layer of complexity here is that actually, case of "If in character, ghost entity: UI no open" is not completly true. From the events raised, the gui is being open, it is just that character update specifically checks if the entity that is opened by the character controller can be opened, and if not then it gets closed. Technically you see no gui but under the hood it gets opened and closed in the same tick. When in remote view, the gui is not opened by the character controller but by a remote controller and the character update does not touch this and so the gui is not closed.
Third layer of complexity here is that the behavior is also slightly different when setting operable=false on the real entity and then allowing it to be destroyed leaving a ghost: in that case its the inner entity that is not operable and the ghost itself can still be operable.
So given those findings, it looks like the entity can be opened if the inner entity is operable, but it gets closed when the outer entity is not operable, and there is no lua api to allow changing operable state of the inner entity. That may not be easy to fix. I could apply a slight fix of making entity not operable if either the outer entity or inner entity is marked as not operable, but that creates a tiny problem if a non operable entity dies and would be then decided to become operable: no lua api would allow making it operable because the ghost already is operable and there is no access to operable of inner entity.
Alternative solution is to make entity ghost to inherit operable flag of the entity being destroyed, and then make all operations that change operable flag target both inner and outer entity so they stay in sync.
Re: [2.0.54] LuaEntity.operable = false does not work on Ghosts in remote view
Posted: Wed Jun 04, 2025 8:46 pm
by Rseding91
I've changed it for the next release so setting/reading operable always forwards it to the inner entity for entity ghosts.