Okay, so the goal is for each enemy in the array Global.enemies
Main node code:
func begin_enemies_turn():
var enemy_team_size = Global.enemies.size()
for i in enemy_team_size:
Global.enemies[i]._current_enemy_turn()
await Global.enemies[i]._current_enemy_turn_ended
print("signal recived")
get_node("Player Screen")._begin_player_turn()
Enemy Scene code:
func _current_enemy_turn():
print(enemy_target_number_local, " began it's turn!")
_end_current_enemy_turn()
func _end_current_enemy_turn():
print(enemy_target_number_local, " ended it's turn!")
_current_enemy_turn_ended.emit()
```
Clearly something is wrong because I get a "infinite loop" alert and the whole thing crashes. I can only assume this is either a problem with the ``await`` command in the ``begin_enemies_turn():`` function, or something wonky with the connection in ``new_enemy._current_enemy_turn_ended.connect(self.begin_enemies_turn)``
My intention was to run each enemy action, wait for it to finish, then run the next enemy action (using the array ``Global.enemies.size()``) and then after every enemy had 1 action run the ``_begin_player_turn`` function and exit the`` begin_enemies_turn():`` function. And I THINK the infinit loop is just playing the first enemy's turn over and over again instead of moving onto the next one, though it's hard to tell with the crash.
How am I creating an infinite loop, and how do I stop it?