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

Level:shine-getter

#1

Whats wrong?

    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);
          
        }
    }
}
#2

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) {

and that will fix that little, oops.

#3

Stupid mistake((( Big thanks!!

#4

Mod edit: Please do not post for assistance in multiple locations for the same issue. You will not receive assistance faster with multiple posts.