No yield in the setters in ActiveTurnQueue?


I learned from your tutorials that setters get called when objects enter the tree, which happens before ready/onready signals. On the ActiveTurnQueue you have two setters that iterate over 'battlers' which is an array created in the onready function. But for some reason it isn't throwing an error even though you aren't yielding until ready, so I think I'm missing something.

How are you able to iterate over 'battlers' in a setter function, when battlers aren't defined until ready is called?

Thank you

  • Nathan Lovato replied

    Which functions are we talking about exactly? If it's this one:

    func set_is_active(value: bool) -> void:
        is_active = value
        for battler in battlers:
            battler.is_active = is_active

    Then the reason it doesn't throw errors is that at init time, battlers is an empty array, thus the loop never tries to access a battler. But when this gets called again later in the game, then the array's populated with battlers.

    That's why this one function doesn't throw errors.