while True: enemy = hero.findNearestEnemy() item = hero.findNearestItem() # If there is no enemy, continue out of the loop. if not enemy: continue # If there is no item, ask for a potion then continue: if not item: hero.say("Give me a drink!") continue # If the item.type "poison", continue out of the loop. if item.type == "poison": continue # At this point, the potion must be a bottle of water # so moveXY to the potion, then back to the start! hero.moveXY(44, 35) hero.moveXY(34, 47)
My hero does it correctly the first time, but then she stops for a second and the ogres get some water.