Decoy Drill Issues - Javascript

I am having trouble with Decoy Drill. I am collecting way too much gold before building a decoy. If I take out the pice of code that says totalGold=0; after building a decoy, my guy simply stops.

Thoughts?

var decoysBuilt = 0;
var totalGold = 0;
loop {
  
    var coin = this.findNearestItem();
    this.moveXY(coin.pos.x, coin.pos.y);
    var value = coin.value;
    totalGold = totalGold + value;
    
    
    if (totalGold >= 25) {
        this.buildXY("decoy", this.pos.x, this.pos.y);
        decoysBuilt = decoysBuilt + 1;
        totalGold=0;
    }
    
    if (decoysBuilt >= 4) {
        break;
    }
        
}

this.say("Done building decoys!");
// Go to Naria and say how many decoys you built.
this.moveXY(14, 36);
this.say("I have built "+decoysBuilt+" decoys.");

pro tip. put three of these characters on a line by itself both before and after your pasted code. `

Try using the this.gold from your sense stone on this one, since you can’t count the gold you incidentally pick up on the way to get your target coin just by summing coin.value numbers.

1 Like