In my opinion string
if enemy.type != "sand-yak":
is in wrong position from very beginning. Or maybe it is for purpose
loop: enemies = self.findEnemies() enemyIndex = 0 # Wrap this logic in a while loop to attack all enemies. enemy = enemies[enemyIndex] # "!=" means "not equal to." if enemy.type != "sand-yak": # While the enemy's health is greater than 0, attack it! pass
Iv been testing many variations with original script. None worked for me at least with simple correction. It might confuse most of the beginners.
What the rest of players think about that?
loop: enemies = self.findEnemies() enemyIndex = 0 while enemyIndex < len(enemies): enemy = enemies[enemyIndex] enemyIndex = enemyIndex + 1 for enemy in enemies: if enemy.type != "sand-yak": while enemy.health > 0: if self.isReady("power-up"): self.powerUp() else: self.attack(enemy)