I’m using Python!
# You can put one if-statement within another if-statement. # Be careful how the if statements interact with each other. # Make sure the indentation is correct! # It's helpful to start with one outer if/else, # using comments as placeholders for the inner if/else: loop: enemy = self.findNearestEnemy() # If there is an enemy, then... if enemy: # Create a distance variable with distanceTo. distance = self.distanceTo("Munchkin") # If the distance is less than 5 meters, then attack. if distance > 5: self.attack(enemy) self.attack(enemy) # Else (the enemy is far away), then shield. else: self.shield() # Else (there is no enemy)... else: # ... then move back to the X. self.moveXY(40, 34)