while (true) {
var coin = hero.findNearest(hero.findItems());
while(coin) {
hero.moveXY(coin.pos.x, coin.pos.y);
}
coin = hero.findNearest(hero.findItems());
var enemy = hero.findNearestEnemy();
if (enemy) {
while(enemy.health > 0) {
hero.attack(enemy);
}
}
}
Hey guys why is this code doesn’t work?