Help With Shine Getter


#1

So I’ve been stuck on the level Shine Getter in the Desert World, and I need some help.
So, I’m not sure what’s wrong with my code, but if anyone could help me out, I would appreciate it.
My code:

> loop:
>      coins = self.findItems()
>      coinIndex = 0
>      while coinIndex > len(coins):
>         coin = coins[coinIndex]
>          if coin.value == 3:
>              self.moveXY(coin.pos.x, coin.pos.y)
>             coinIndex += 1

#2

Your while-loop entails while coinIndex > len(coins):. The problem is, coinIndex is zero, and therefore is never greater then the amount of coins. I don’t suppose you meant while coinIndex < len(coins):?


#3

Then I just get a “Hard Execution Limit of 3 Million”


#4

Your indentations are also a little mixed up. If my assumptions are correct, you only increment coinIndex when you pick up a gold coin. This should not be. You want to loop over all coins.


#5

Just tried it when you find a gold coin, not when you walk over it, and it worked. Thanks for your help


#6

Lol I just got the 100 levels achievement and got 1,000 gems, too. :grinning: