Why Is Gdscript Not Printing During This While Loop?

I am working with the following while loop in GDScript:

while tunnels_carved < num_tunnels:
    ...
    .
    .
    tunnels_carved += 1
    print("Generation at ", round(tunnels_carved / num_tunnels * 100), "%")

This is contained within a method for an object that extends TileMap.

This issue I'm having is that none of the calls to print send anything to the output stream until the entire while loop is completed; at which point it spits out every line at the same time. If the code encounters a break-point during the while loop, the print functions begin to work as expected. Is there a way to force GDScript to print these strings before moving to the next iteration of the while loop?

I don't think the rest of the code in the while loop is pertinent, but if it is, I would be be more than happy to share it.

Edit: I've noticed the strings do get printed to the OS terminal window at the appropriate time. I suppose this will do well enough. If anyone knows how to get the Godot Editor's console to display these strings at the appropriate time, please let me know.

2
Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article