Tell me that did not, the level of exercise with the bait


#1

I can not understand what is wrong, collecting bait, but gathering process continues, why not appropriate and does not say that gathered 4 bait.

loop {
    var item = this.findNearestItem();
    if(item)   {
        var Gold = item.pos;
        var x = Gold.x;
        var y = Gold.y;
        this.moveXY(x, y);
    }
   var totalGold = this.gold;
    if (totalGold >= 25) {
       this.buildXY("decoy", 7, 30);
   }
      var  decoysBuilt = this.decoy;
       if( decoysBuilt >= 4)
  {
         break;
   }
}
this.moveXY(14, 36);
this.say("decoy collected!");
this.say("4 pieces!");

#2

Try initializing a decoysBuilt variable before your loop, and then in the loop, increment it when you build a decoy:

var decoysBuilt = 0;
loop {
    // ... your code ...
    if (totalGold >= 25) {
        this.buildXY("decoy", 7, 30);
        decoysBuilt = decoysBuilt + 1;
    }
    // ... your other code ...
}
// ... etc. ...