I’m having trouble getting my avatar to actually go around and collect the gold. She just runs straight to Naria and says “Done collecting gold!”. Any suggestions on why the program is ignoring my code?
var totalGold = 0;
loop {
var coin = this.findNearestItem();
// Pick up the coin and add its value to the total.
// Get its value with: coin.value
if (coin) {
var pos = coin.pos;
var x = this.pos.x;
var y = this.pos.y;
this.moveXY(x,y);
totalGold = totalGold += coin.value;
}
if (totalGold >= 25) {
// >= means totalGold is greater than or equal to 25.
// This breaks out of the loop to run code at the bottom.
break;
}
}
this.moveXY(64, 34);
this.say("Done collecting gold!");
Draz, please do not give out correct code, as it gives any reader the answer without providing the learning. Besides, the person you are replying to gave the issue over five months ago. And you still haven’t learned to post your code correctly.