Page 1 of 1

Which LuaGuiElement is in front?

Posted: Fri Apr 29, 2022 5:34 pm
by Pi-C
My mod has 2 GUIs on player.gui.screen. When I turn them on, I will use LuaGuiElement.bring_to_front() to make sure they are visible. One of them ("Available characters") can become quite small, as you can see in this screenshot:
overlay-guis.png (2.79 MiB) Viewed 199 times
In this case the small GUI is on top, so it is visible. But if the bigger GUI gets the focus, the small one will be completely hidden. The button flow at the top left of the screen contains the buttons that toggle GUI visibility. Now, if the small GUI is hidden by something else, clicking the "Available characters" button will (apparently!) do nothing: The GUI already is visible, so using the button will make it invisible, and only on the next click will it be visible (and in the foreground) again.

Is there any way to find out whether a particular GUI element is hidden, or at least if it is on top? If so, I could check whether my GUI is visible but possibly hidden and bring it to the front instead of turning it off when the toggle button is used.

Re: Which LuaGuiElement is in front?

Posted: Sun May 01, 2022 11:44 pm
by yaim904
I would like to help you, but I don't think I understand what the problem is.

If what you want is to prevent the windows from overlapping, place it to one side of the main one

Code: Select all

script.on_event(, function(event)
    local player = game.get_player(event.player_index)
    local anchor = {gui=defines.relative_gui_type.controller_gui,}
    local frame = player.gui.relative.add{type="frame", anchor=anchor}

While you don't need the window, hide it with the " = false" property or destroy it.