Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Decoy Drill Javascript

Hi guys, i have a problem in this lvl, i dont understand why the character picking always more then 25 gold and after only building decoy, im losing time with it and cannot complete quest in time, in previous lvl it pick exactly 25 gold with that gold, i just do not understand…

Here is code:

var gold = 0;
var decoysBuilt = 0;
loop {
var coin = this.findNearestItem();
if (coin){
var pos = coin.pos;
var x = pos.x;
var y = pos.y;
this.moveXY(x, y);
gold = gold + coin.value;

if (gold >= 25) {
this.buildXY(“decoy”, x, y);
decoysBuilt = decoysBuilt + 1;
gold = 0;

if(decoysBuilt == 4) {


this.say(“Done building decoys!”);
this.moveXY(14, 36);

Ok i get it now, instead of
if (gold >= 25)
i had to type
if (>= 25)

I wont delete treat in case if someone will get the same problem and wont have solution.

Here, this page might help.

1 Like