So… Below Is My Code. It Should Work, But I get a Message Saying “Try hero.pos” On Line 18. I Don’t Know Why! Is This A Bug? Please Help.
// Accumulate 300 gold and escape from the dungeon.
function onSpawn(event) {
// Send the pet to walk around the dungeon:
var coin = pet.findNearestByType("gold-coin");
pet.moveXY(coin.pos.x,coin.pos.y);
// Don't forget to return it to the hero:
pet.moveXY(hero.pos.x,hero.pos.y);
}
pet.on("spawn", onSpawn);
while(true) {
// Guard peasants:
var enemy = hero.findNearestEnemy();
if (enemy) {
hero.attack(enemy);
}
// When you have 300+ gold move to the red mark:
if (hero.gold > 300) {
hero.moveXY(50, 34);
}
}