[SOLVED] Help: Hoarding Gold

i cant figure out how to make the game understand the property"value"

please help me

# Collect 25 gold, and then tell Naria the total.
# Use break to stop collecting when totalGold >= 25.
totalGold += coin.value
totalGold = 0
while True:
    coin = hero.findNearestItem()
    if coin:
        # Pick up the coin.
        hero.moveXY(coin.pos.x, coin.pos.y)
        # Add the coin's value to totalGold.
        # Get its value with:  coin.value
        coin.value
        pass
    if totalGold >= 25:
        # This breaks out of the loop to run code at the bottom.
        # The loop ends, code after the loop will run.
        break

# Done collecting gold!
hero.moveXY(58, 33)
# Go to Naria and say how much gold you collected.
hero.say("Hi Naria I collected " + totalGold + " gold!")

I think the issue is that you haven’t defined value in your code

replace this

with this

totalGold = totalGold + coin.value

how do i define it?(20 char)

You seemed to define totalGold but not the value

Do this @logan_jordan

oh ok i will try that

in what line do i put totalGold = totalGold + coin.value this in

i have a problem on line 3

Show your new code now.

# Collect 25 gold, and then tell Naria the total.
# Use break to stop collecting when totalGold >= 25.
totalGold += coin.value   this is the problemed line
totalGold = 0
while True:
    coin = hero.findNearestItem()
    if coin:
        # Pick up the coin.
        hero.moveXY(coin.pos.x, coin.pos.y)
        # Add the coin's value to totalGold.
        # Get its value with:  coin.value
        totalGold = totalGold + coin.value
        pass
    if totalGold >= 25:
        # This breaks out of the loop to run code at the bottom.
        # The loop ends, code after the loop will run.
        break

# Done collecting gold!
hero.moveXY(58, 33)
# Go to Naria and say how much gold you collected.
hero.say("Hi Naria I collected " + totalGold + " gold!")

Get rid of that line then you are good

ok thanks let me try that

i got it thanks man you helped alot

So who solved it me or @milton.jinich just wondering

1 Like

Bruh you needa chillout its not that serious

1 Like

I meant it as a joke not an act of aggression

milton and you both solved it

I know I was just messing around

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.