Shine Getter help


#1

I’m sorry for posting again, but i’m trying my best to learn and i’m struggling.

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.
        hero.moveXY(coins.pos.x, coins.pos.y)
    coinIndex += 1
pass

#2

It’s mostly a structure problem. The if coin.value ==3: conditional and the incremental statement should be inside the while coinIndex loop. Also, your move statement X & Y positions should be singular.


#3

nothing to be ashamed of except possibly embarrassment.

and, you could only go to one coin at a time. instead of coins.pos.x, replace coins for coin. do the same for y position.


#4

This is my code now but nothing changed. :frowning:

while True:
coins = hero.findItems()
coinIndex = 0

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

pass


#5

Half your code isn’t formatted so I can’t see the structure. Please put all of it inside the triple back ticks.


#6
while True:
coins = hero.findItems()
coinIndex = 0

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

#7

Experiment with your code. There’s one line that needs to be tabbed over. The code is correct, the structure is the issue.


#8

To the left or to the right?


#9

Seriously? Code Combat is a learning tool. Learning to code is extremely difficult if someone just gives you the answers. Please experiment with your code and learn. Make sure all of your code is inside the while true loop.


#10

Remember, you’re trying to loop all code inside it. So all of the code you want to be looped has to be inside the while true loop. So all code you want to be looped has to be indented in the loop. Please make a better effort than this, debugging involves experimenting with code.


#11

At this point I would highly recommend going back and reviewing/redoing some previous levels. There are some basic concepts involving structure that must be learned and without an understanding of those concepts, it’s only going to get more difficult from here.


#12

with this, you can’t do anything, except watching beautiful coins.