Here’s my code:
# Use "if" and "else if" to handle any situation. # Put it all together to defeat enemies and pick up coins! # Make sure you bought great armor from the item shop! 400 health recommended. loop: flag = self.findFlag() enemies = self.findEnemies() items = self.findItems() if flag: # What happens when I find a flag? self.pickUpFlag(flag) elif enemies: # What happens when I find an enemy? for enemy in enemies: if self.isReady("cleave"): self.cleave(enemy) else: self.attack(enemy) else: for item in items: if item: position = item.pos x = position.x y = position.y self.moveXY(x, y) self.say("Money!")
Only the first part of my code is executing. I can place flags and attack enemies both cleave and attack work but he won’t pick up items automatically. I also reversed my enemy and item statements then I could place flags and automatically pick up items but he wouldn’t attack enemies or cleave. When I run the check-marks do not go beyond the second if statement. Please help.