Replacing the GUI for a custom constant-combinator

Place to get help with not working mods / modding interface.
Post Reply
mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Replacing the GUI for a custom constant-combinator

Post by mrvn »

In my mod I have a custom constant combinator. I've added the technology, recipe, item, entity prototypes and graphics for it. I can research the tech, craft the item and place the entity.

Now when the player clicks at my custom combinator the vanilla constant combinator GUI opens. I want to replace that with my own window that behaves just like the vanilla one.

Meaning:
- centered on the screen
- draggable with the mouse
- closes on ESC or E (close window hotkey)
- closes when another GUI is opened

How do I do that?

What I have tried so far is catching the on_gui_opened and on_gui_closed events. In on_gui_open I can create my own frame and fill it with some test elements. But then it's just hidden under the vanilla constant combinator GUI. If I set "player.opened = my_frame" then the vanilla GUI gets closed right away leaving just mine (on_gui_closed gets called for the entity). But it doesn't behave like a game window, doesn't close on ESC or E or when the crafting window is opened. on_gui_closed never gets called for my GUI.

mrvn
Smart Inserter
Smart Inserter
Posts: 5709
Joined: Mon Sep 05, 2016 9:10 am
Contact:

Re: Replacing the GUI for a custom constant-combinator

Post by mrvn »

Never mind. After some sleep I finally found the problem. I had a typo in the final line:
player.opened = main_fame
So it assigned "nil" instead of my GUI, which then breaks closing the window. I figured out the rest from Bobs adjustable inserters mod.

Post Reply

Return to “Modding help”