I think I might not be understanding yield, or this is potentially a bug, I'm not sure. I have the following segment of code:
var loading_scene = loading.instance()
print("reached here, before game setup")
var game_scene = game.instance()
For context, "gamesetup()" is a function that tends to take 3-6 seconds or so, and I'm putting a loading screen while it waits. The loading screen scene is literally just a blank space, the word "loading", and a little icon. If I run the code as it is now, with "yield" commented out, the loading scene never appears (or it possibly briefly appears, and is then immediately cleared at "loadingscene.queue_free()") . Essentially, what I think is happening is for some reason, it's waiting until the end of this script to try and add it to the scene. When I run the game, the loading happens and it proceeds to the next stage without a problem, but the loading screen never appears. So I know for certain that "gamesetup() *is* happening.
The strange behaviour is when I uncomment the "yield" line, then, all of a sudden, the loading screen appears, hangs for 5 seconds (as I've made it do) and then everything proceeds as normal.
What is happening here? Why does the loading scene only appear on-screen if there is a "yield" in the middle of the script?