Level "Shine Getter", Nothing Happening? Python

This is my code,

# To grab the most gold quickly, just go after gold coins.

while True:
    coins = hero.findItems()
    coinIndex = 0
    
    # Wrap this into a loop that iterates over all coins.
    while coinIndex < len(coins):
        coin = coins[coinIndex]
        # Gold coins are worth 3.
        if coin.value == 3:
            # Only pick up gold coins.
            coin = coins[coinIndex]
            hero.moveXY(coin.pos.x, coin.pos.y)
            coinIndex += 1
            pass

I click run yet nothing happens not even an error just says “running…”
I have been stuck for a while not knowing if it is a bug or just my code,
so I decided to post here after looking all over google and here.

Your code may be too long. Make sure you have the right equipment…

1 Like

Could you send a screenshot?

2 Likes

It could be that you have a dead / infinite loop by accident or your computer is running slow.

2 Likes

#Do not put
coinIndex += 1
#in “if statement”.

4 Likes

Thank you jack! This worked I had no idea that was what I was doing wrong.

1 Like

Bravo! same problem and same solution!

while True:
    coins = hero.findItems()
    coinIndex = 0
    return 
    # Wrap this into a loop that iterates over all coins.
    while coinIndex < len(coins):
        coin = coins[coinIndex]
    # Gold coins are worth 3.
    if coin.value == 3:
        # Only pick up gold coins.
        hero.moveXY(coin.value.x, coin.value.y)
        pass
        

I am not moving plz help me.

Hi,
There are a few problems in here, I’ll tell you the biggy: you’ve put a return in your code this means it will keep going back to the top.
After you’ve got rid of that, there are some other problems but I think you might be able to fix them now.
Danny

thanks danny

[en_US.composer.my_button_text]

1 Like