Work on the gui of an entity

Place to get help with not working mods / modding interface.
Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Work on the gui of an entity

Post 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
Rseding91
Factorio Staff
Factorio Staff
Posts: 15997
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Work on the gui of an entity

Post by Rseding91 »

It's not possible.
If you want to get ahold of me I'm almost always on Discord.
Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Re: Work on the gui of an entity

Post by Hermios »

But... why?? :(
Seriously, could it be implemented? It would be great!
User avatar
aubergine18
Smart Inserter
Smart Inserter
Posts: 1264
Joined: Fri Jul 22, 2016 8:51 pm
Contact:

Re: Work on the gui of an entity

Post 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.
Better forum search for modders: Enclose your search term in quotes, eg. "font_color" or "custom-input" - it prevents the forum search from splitting on hypens and underscores, resulting in much more accurate results.
Rseding91
Factorio Staff
Factorio Staff
Posts: 15997
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: Work on the gui of an entity

Post 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.
If you want to get ahold of me I'm almost always on Discord.
Hermios
Long Handed Inserter
Long Handed Inserter
Posts: 80
Joined: Sat Aug 13, 2016 2:57 pm
Contact:

Re: Work on the gui of an entity

Post by Hermios »

Life is tough! :roll:
Well, I found a solution, wich is not so pretty, but it works.
Thanks for your help
Post Reply

Return to “Modding help”