I am stuck on this level. When Omarn says “Fetch!”, it is AFTER I die. When she does say “Fetch!” BEFORE I die however, the pet carries the potion to my hero, but never delivers it and turns around instead.
Code:
// Wait for alchemist’s commands to fetch potions.
// The event handler for the pet’s event “hear”.
function onHear(event) {
// Find the nearest potion.
var potion = pet.findNearestByType(“potion”);
// If the event’s message is “Fetch”
if (event.message == “Fetch”) {
pet.fetch(potion);
}else{
pet.moveXY(54, 34);
}
// Have the pet fetch the potion.
// Else (for any other messages):
// Return the pet to the red mark.
}
pet.on(“hear”, onHear);
// You don’t have to change the code below.
while(true) {
var enemy = hero.findNearest(hero.findEnemies());
if (enemy) {
hero.attack(enemy);
}
else {
hero.moveXY(40, 34);
}
}