When does print statement display in godot 3

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Karl Marx

I am trying to debug a crash in my game which happens when the player clicks the screen to place a stone (I am making a Go game). I have been trying to use the print function to work out how far the code gets before crashing but nothing is printed even when placing the print function right at the start of the faulty code (in _on_CenterContainer_gui_input). I was wondering when godot displays the printed string in the output panel, and if a crash could cause all previous print functions in the same frame to not be shown. If a crash could be suppressing the prints then is there a way to force godot to update the output panel before continuing to the crash-causing code.

It sounds like you’re running your game “in editor”? If that’s true, why not use the in-built debugger instead? That’d allow you to set some break-points at appropriate places, step through the code a line at at time, and examine relevant data along the way.

Regarding the question about print, I don’t really know the answer. I can imagine there’s some kind of (internal) flush operation that needs to be performed between your print code being processed and the output actually being shown in the console. If the crash happens prior to such an operation, you probably wouldn’t see the output. Though, that’s really just a guess…

jgodfrey | 2023-05-11 14:54

Thanks, I had completely overlooked the in-built debugger and have now solved the crash. Your response about the print not showing also made sense. Thanks again.

Karl Marx | 2023-05-11 22:56