var coins = this.findItems();
var coinIndex = 0;
loop {
while (coinIndex < coins.length) {
// Wrap this into a loop that iterates over all coins.
var coin = coins[coinIndex];
coinIndex = coinIndex + 1;
// Gold coins are worth 3.
if (coin.value == 3) {
// Only pick up gold coins.
var coinp = coin.pos;
var x = coinp.x;
var y = coinp.y;
this.moveXY(x, y);
}
}
}
Please help us help you . . . by telling what is going wrong…
I’d guess that since you assign coins and coinIndex outside the “loop” that you only pick up coins that existed when the “run” starts and ignore new ones.
var coins = this.findItems();
var coinIndex = 0;
loop {
while (coinIndex < coins.length) {
make it
loop {
var coins = this.findItems();
var coinIndex = 0;
while (coinIndex < coins.length) {