Adding the ability to force open a different entity's GUI

Place to ask discuss and request the modding support of Factorio. Don't request mods here.
Post Reply
orangedude27
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Aug 11, 2017 2:02 am
Contact:

Adding the ability to force open a different entity's GUI

Post by orangedude27 »

TL;DR
Allow the ability of a on trigger open entity's gui

What ?
What i would like to see added is the ability to use a event.on_xxx function to be able to open a entity's gui. For example, I have a thing i am working on where two inserters are occupying the same location in space. One of them is not selectable, and therefor i can't press "e" on it. What would be cool is have the ability in the scripts to force open that gui when I want to via some entity.open_gui.

curiosity
Filter Inserter
Filter Inserter
Posts: 326
Joined: Wed Sep 11, 2019 4:13 pm
Contact:

Re: Adding the ability to force open a different entity's GUI

Post by curiosity »

Did something happen to player.opened?

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Adding the ability to force open a different entity's GUI

Post by Deadlock989 »

curiosity wrote:
Tue Dec 12, 2023 10:35 am
Did something happen to player.opened?
Either be helpful and civil or don't post. No-one wants your vinegar.
Image

orangedude27
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Aug 11, 2017 2:02 am
Contact:

Re: Adding the ability to force open a different entity's GUI

Post by orangedude27 »

I see that player.opened is there. Do I just set it equal to the entity from some event?

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Adding the ability to force open a different entity's GUI

Post by Deadlock989 »

orangedude27 wrote:
Tue Dec 12, 2023 2:38 pm
I see that player.opened is there. Do I just set it equal to the entity from some event?
It doesn't have to be the entity from an event but it can be. If you set it to a LuaEntity and that entity actually has a GUI, any currently open entity GUI will be closed and the given entity's GUI opened (raising on_gui_opened, so avoid getting stuck in a loop there).

Be aware that in previous versions of Factorio there was some latency for non-hosting players if you change player.opened in on_gui_opened in order to cancel one gui and open another. I haven't tested it recently but I assume it hasn't changed. It's nothing breaking, just an irritation, and doesn't affect single player games.
Image

orangedude27
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Aug 11, 2017 2:02 am
Contact:

Re: Adding the ability to force open a different entity's GUI

Post by orangedude27 »

Ok cool,

So based on that then, and what I've read in the docs, you can't multiple gui menus open originating from two different entities? What would be cool is either the ability to make a composite GUI element, or to just have multiple active GUIs. Maybe it is possible and I just lack the knowledge to do so. Any help is welcomed.

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Adding the ability to force open a different entity's GUI

Post by Deadlock989 »

You can't have multiple entity GUIs open at once. You can have multiple custom GUIs however. When you say "composite GUI" I don't know exactly what you mean but the first things that springs to mind is relative GUIs. These are GUI elements that you can attach to any of the four sides of a vanilla GUI, including specific entity GUIs:

https://github.com/ClaudeMetz/UntitledG ... nilla-GUIs
Image

orangedude27
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Aug 11, 2017 2:02 am
Contact:

Re: Adding the ability to force open a different entity's GUI

Post by orangedude27 »

So let's say I already have one inserter GUI open, would this allow me to open the "unselectable" entity's GUI as a relative GUI or is this specific to only mod-based GUIs? or would i need to recreate that as a relative gui element?

User avatar
Deadlock989
Smart Inserter
Smart Inserter
Posts: 2528
Joined: Fri Nov 06, 2015 7:41 pm

Re: Adding the ability to force open a different entity's GUI

Post by Deadlock989 »

Relative GUIs can only be custom GUIs, yes. You can't open an entity GUI and give it another entity GUI as the anchor.

If you want one GUI to open which can control aspects of both inserters then yes, either you will need to create a completely new custom GUI with controls that affect both of them, or create a custom relative GUI that attaches to the first inserter's native GUI with controls that change whatever properties of the second inserter you're interested in.
Image

orangedude27
Burner Inserter
Burner Inserter
Posts: 6
Joined: Fri Aug 11, 2017 2:02 am
Contact:

Re: Adding the ability to force open a different entity's GUI

Post by orangedude27 »

Deadlock989 wrote:
Tue Dec 12, 2023 3:43 pm
or create a custom relative GUI that attaches to the first inserter's native GUI with controls that change whatever properties of the second inserter you're interested in.
Ok so the options are, to start from scratch, or do a half and half (half native and half relative).

So then I guess my requested feature is more along the lines of: Allowing multiple GUIs to be opened at once, which is beyond the scope of this thread, probably?

Post Reply

Return to “Modding interface requests”