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

This subforum contains all the issues which we already resolved.
User avatar
mickael9
Fast Inserter
Fast Inserter
Posts: 112
Joined: Mon Mar 14, 2016 4:04 am
Contact:

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

Post 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 3859 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?
Attachments
gui-crash_0.0.1.zip
(678 Bytes) Downloaded 143 times
Nexela
Smart Inserter
Smart Inserter
Posts: 1828
Joined: Wed May 25, 2016 11:09 am
Contact:

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Post 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!
User avatar
mickael9
Fast Inserter
Fast Inserter
Posts: 112
Joined: Mon Mar 14, 2016 4:04 am
Contact:

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Post by mickael9 »

Ah ok, makes sense :)

Congrats on your 500th post :P
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Post 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.
matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

Re: [0.14.4] Error in on_gui_click causes uncloseable dialog

Post 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.
Rseding91
Factorio Staff
Factorio Staff
Posts: 14281
Joined: Wed Jun 11, 2014 5:23 am
Contact:

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

Post by Rseding91 »

Fixed for 0.14.6.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

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

Post by Mooncat »

Rseding91 wrote:Fixed for 0.14.6.
Thanks~ :D
matjojo
Filter Inserter
Filter Inserter
Posts: 337
Joined: Wed Jun 17, 2015 6:08 pm
Contact:

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

Post 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.
Post Reply

Return to “Resolved Problems and Bugs”