Shine Getter Help (2)

Can someone help me with my code, please?

# 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):
        
        # Gold coins are worth 3.
        if coins.value == 3:
            # Only pick up gold coins.
            hero.moveXY(coins.pos.x, coins.pos.y)
        coinIndex += 1
    pass
        

hero won’t move

coins is defined as an array, not a single item, so there is no single position to move to. You have to define coin and then move to the coin.pos.

Can you show me how to do that?

coin = coins[coinIndex]

Remember this chunk of code. You’re going to be seeing this format a LOT.

Like this

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 coins.value == 3:
            # Only pick up gold coins.
            hero.moveXY(coins.pos.x, coins.pos.y)
        coinIndex += 1
    pass

you still didn’t change the places where you refer to coins instead of coin.

like this

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 coins.value == 3:
            # Only pick up gold coins.
            hero.moveXY(coin.pos.x, coin.pos.y)
        coinIndex += 1
    pass

I figured it out now

1 Like

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

can someone help me with this code:

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 coins.value == 3:
        # Only pick up gold coins.
        hero.moveXY(coin.pos.x, coin.pos.y)
    coinIndex += 1
pass

my hero will not move

You define the variable, coin, but don’t use it. Coins is plural. Coins cannot have a value equal to 3 because coins is an array. Look closely at what you’ve written. :wink:

1 Like

can you show me how did it work for you cuz i still can’t find the place for coin = coins[coinIndex]

1 Like

Hi @G4NG and welcome to the forum. Can you show us your code?

1 Like

i solved it but i need help with another code
well i have problem with wishing well
ill write my code here and if you can resend me with corrected errors

1 Like

You could create another topic for that

1 Like

I solved thanks anyways.Im at the last level in desert clash of clones.Do you have the solution for it?

Sorry, but we don’t give solutions…we provide guidance and hints to help you with your code.

As AnseDra mentioned, please start a new topic to get help with a different level.

1 Like

Ok i thought you are giving solutions.But anyways your forum helped me a lot BIG THANKS!!!

You should try to find your own tactic to beat the level and, if you have any troubles, ask us on the forum.

1 Like