Decoy Drill (Javascript) [Solved]

I just seem to get stuck on the easier things…

var decoysBuilt = 0;
while (true) {
    var coin = hero.findNearestItem();
    if (coin) {
        hero.moveXY(hero.pos.x, hero.pos.y);
    }
    if (hero.gold >= 25) {
        // buildXY a "decoy"
        hero.buildXY("decoy", hero.pos.x, hero.pos.y);
        decoysBuilt += 1;
    }
    if (decoysBuilt == 4) {
        break;
    }
}
hero.say("Done building decoys!");
hero.moveXY(14, 36);
hero.say(decoysBuilt);

Why are you moving to the hero’s position if there is a coin? You should be moving to the coin’s position.

2 Likes

Oh I didn’t realize that! Thank you

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.