Page 1 of 1
Work on the gui of an entity
Posted: Fri Dec 30, 2016 3:08 pm
by Hermios
Hi
How can I reach the gui of an entity? I can reach the GUI of a player, I can reach the entity whose gui is opened, but I cannot reach the gui itself. Is this possible? and if so, how?
THanks
Niko
Re: Work on the gui of an entity
Posted: Fri Dec 30, 2016 4:13 pm
by Rseding91
It's not possible.
Re: Work on the gui of an entity
Posted: Fri Dec 30, 2016 4:16 pm
by Hermios
But... why??
Seriously, could it be implemented? It would be great!
Re: Work on the gui of an entity
Posted: Fri Dec 30, 2016 6:33 pm
by aubergine18
You can detect when an entity is opened via
http://lua-api.factorio.com/latest/LuaC ... rol.opened
But there's no way to get a handle to the GUI or change it's contents.
Some "workarounds" exist. For example, you can mod an item that doesn't have a GUI and then use .selected to see when player selects it:
http://lua-api.factorio.com/latest/LuaC ... l.selected
Once you detect an appropriate selection, you can draw your own GUI.
Another alternate is to have a "custom-input" (keyboard shortcut) that can be used to open custom GUI for selected entity.
Re: Work on the gui of an entity
Posted: Fri Dec 30, 2016 8:06 pm
by Rseding91
Hermios wrote:But... why??
Seriously, could it be implemented? It would be great!
Because the GUIs we create contain information that isn't deterministic and isn't always guaranteed to be safe to read from at any given point in time. Allowing mods to read it would lead to desyncs and crashes.
Re: Work on the gui of an entity
Posted: Fri Dec 30, 2016 8:09 pm
by Hermios
Life is tough!
Well, I found a solution, wich is not so pretty, but it works.
Thanks for your help