In the following GDScript pseudocode, is statement B guaranteed to execute before statement A?

(This is mainly for Godot 4, but probably isn't specific to the Godot version.)

Node 1 script

func _ready():
	deferred_init.call_deferred()

func deferred_init():
	emit signal S
	statement A

Node 2 script

func _ready():
	connect signal S to function F

func F():
	statement B
  • xyz replied to this.
  • DaveTheCoder Yes, but it looks like something you should handle in less convoluted way... if you can.

    DaveTheCoder Yes, but it looks like something you should handle in less convoluted way... if you can.

    The reason I'm using a signal, rather than a function call, is that Node 2 is not a descendant of Node 1. I thought this would be a modular approach.

    But since Node 2 is an autoload, I could easily use a function call, so maybe you're correct. Then I wouldn't need call_deferred().

    Thanks. 😃