Page 1 of 1

[0.12.6] [kovarex] on_gui_click handler keeps getting called on error

Posted: Sun Sep 06, 2015 4:53 pm
by prg
The on_gui_click event keeps getting fired when the handler causes an error. This isn't something that should happen during normal operation, but it makes debugging a bit harder when I'm trying to figure out how I messed up and the damn terminal is getting spammed with debug output.

Code: Select all

require "defines"

game.on_event(defines.events.on_player_created, function(event)
    game.get_player(event.player_index).gui.left.add{type="button", name="bla", caption="bla"}
end)

num = 0

game.on_event(defines.events.on_gui_click, function(event)
    num = num + 1
    print("on_gui_click called "..tostring(num).." times")
    if num >= 5 then err() end
end)
Click the button five times and the terminal will get spammed with "on_gui_click called x times" till you click the ok button in the error message box. The handler will only be called again if the previous call resulted in an error, if you check for num == 5 in the example, you will only get "on_gui_click called 6 times" as last output, the function won't get called again. This only seems to happen with on_gui_click, not other events.

Re: [0.12.6] [kovarex] on_gui_click handler keeps getting called on error

Posted: Mon Sep 07, 2015 3:24 pm
by kovarex
Thank you for the report, it is fixed for 0.12.7 now.