crystal-bit / godot-game-template

Generic template for Godot games
MIT License
598 stars 47 forks source link

Await `pre_start()` to be completed before triggering fade out transition #66

Closed davcri closed 2 years ago

davcri commented 2 years ago

See https://github.com/crystal-bit/godot-game-template/commit/9aa7076fc53f98ca9ba50f34b78f6cac7457636b

Iftahh commented 2 years ago

I think this will crash if pre_start has no yield in it -

to avoid a crash:

if instanced_scn.has_method("pre_start"):
    var coroutine_state = instanced_scn.pre_start(_params)
    if coroutine_state is GDScriptFunctionState && coroutine_state.is_valid():
        # wait for coroutine to finish...
        yield(coroutine_state, "completed")
    # else... this is a normal function that just ended
davcri commented 2 years ago

You're right! Thanks for providing the fix! In the future feel free to open a pull request :)