Page 1 of 1

[0.14.4] [Rseding91] Error in on_gui_click causes uncloseable dialog

Posted: Tue Sep 06, 2016 7:12 pm
by mickael9
If a lua error happens in the on_gui_click event handler, the error message will be shown but the user won't be able to close it.

Code to reproduce:

Code: Select all

script.on_event(defines.events.on_gui_click, function(event)
    error("oops")
end)

script.on_init(function(event)
    for name, player in pairs(game.players) do
        player.gui.center.add{type = "button", name = "crash_button", caption = "Click me!"}
    end
end)
sshot.png
sshot.png (1.01 MiB) Viewed 4159 times
I also noticed that the button is not created when creating a new save (only when loading an existing save). Is that a bug I should report?

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Posted: Tue Sep 06, 2016 9:25 pm
by Nexela
mickael9 wrote:I also noticed that the button is not created when creating a new save (only when loading an existing save). Is that a bug I should report?
on_init only runs ONCE when the mod is first installed into a save. The first time a game is created there are NO players in game.players until after on_player_created

if you move your code from on_init to on_player_created then it will run when your player is created, however it will not run on subsequent saves because your player is already created in that save.

Subsequent saves will need to use on_configuration_changed (code here will run anytime base or any mod is added/removed/updated) and on_load However on_load is special so make sure to read up on it!

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Posted: Tue Sep 06, 2016 9:29 pm
by mickael9
Ah ok, makes sense :)

Congrats on your 500th post :P

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Posted: Thu Sep 08, 2016 6:23 pm
by Mooncat
Just wanted to write a report for this bug, and then saw this. :lol:

I don't recall we have this bug before even though I made many mistakes when making GUI, so I tested with different Factorio versions.
I can confirm that 0.13.20 doesn't have this bug, but it exists in all the 0.14 builds.

It seems that the button that causes error is still having higher priority for interactivity than the error dialog despite being drawn under the dialog. You can check this by hovering the button.

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Posted: Thu Sep 08, 2016 7:22 pm
by matjojo
Just wanted to say that I'm getting the same problem here, got a GUI button that causes an error, and I cannot click anything after the 'Notice' comes up.

Re: [0.14.4] [Rseding91] Error in on_gui_click causes uncloseable dialog

Posted: Tue Sep 13, 2016 5:03 pm
by Rseding91
Fixed for 0.14.6.

Re: [0.14.4] [Rseding91] Error in on_gui_click causes uncloseable dialog

Posted: Tue Sep 13, 2016 6:27 pm
by Mooncat
Rseding91 wrote:Fixed for 0.14.6.
Thanks~ :D

Re: [0.14.4] [Rseding91] Error in on_gui_click causes uncloseable dialog

Posted: Tue Sep 13, 2016 7:47 pm
by matjojo
Rseding91 wrote:Fixed for 0.14.6.

literally my hero, the whole team actually, look at all the fixes in the fixed for next release tab, amazing.