Page 1 of 1

How do I open a GUI with the radar?

Posted: Mon Jul 28, 2025 3:08 am
by yaim904
I have a GUI that I want to open with the Radars.
When I try to open the radar GUI, the on_gui_opened event is not triggered.

Code: Select all

script.on_event({
    defines.events.on_gui_opened
}, function(event)
    game.players[event.player_index].print("Event: Actived")
end)
What am I doing wrong?
How do I fix it?

Re: How do I open a GUI with the radar?

Posted: Tue Jul 29, 2025 9:57 am
by Osmo
You are wrapping defines.events.xxx in parentheses, thus providing a table when the on_event function expects a defines.events number or a string of the same name. Remove the {} and it should work. (assuming radars even have gui, i don't remember if they do with energy sources other than burner)

Re: How do I open a GUI with the radar?

Posted: Tue Jul 29, 2025 2:14 pm
by Natha
Osmo wrote: Tue Jul 29, 2025 9:57 am You are wrapping defines.events.xxx in parentheses, thus providing a table when the on_event function expects a defines.events number or a string of the same name. Remove the {} and it should work. (assuming radars even have gui, i don't remember if they do with energy sources other than burner)
A table is totally fine
For me, the radar doesnt have a GUI.

Re: How do I open a GUI with the radar?

Posted: Tue Jul 29, 2025 7:25 pm
by yaim904
Osmo wrote: Tue Jul 29, 2025 9:57 am
Natha wrote: Tue Jul 29, 2025 2:14 pm

What you mean is...
It only works if the entity prototype has a GUI?

I can only find two entities that meet the requirements I'm looking for (Radar and Roboport):
1. The animation is infinite from the moment it is created (without player intervention).
2. It allows red and green cables to be connected.
3. It consumes energy.

If you are right:
4. It must have a GUI.
And that would rule out Radar.

If you know of another type of entity that meets the requirements, please let me know.

Re: How do I open a GUI with the radar?

Posted: Tue Jul 29, 2025 9:38 pm
by Osmo
yaim904 wrote: Tue Jul 29, 2025 7:25 pm 1. The animation is infinite from the moment it is created (without player intervention).
Actually, any entity can have that, its called a stateless visualisation, an animation that plays regardless of the state of the entity or the game. Creating a continuos looping animation is easy.
Note however that this means it plays regardless of whether the machine is powered or not.

So the requirements are:
1. Consumes energy
2. Allows circuit wire connections
3. Has a GUI.

And that covers a lot of entities. One of the simpler examples is a Lamp.

Re: How do I open a GUI with the radar?

Posted: Wed Jul 30, 2025 1:45 am
by yaim904
Osmo wrote: Tue Jul 29, 2025 9:38 pm
Thanks for the information, I didn't know that property worked that way.

I tried it and it keeps the animation going, but regardless of whether or not it has power.

I tried an electrical interface, but it doesn't have connections for the red and green cables.

The roboport continues to win.