Wishing Well Level Help[SOLVED]

I am struggling to complete the wishing well level.
My character will do things correctly and say non satis and nimis to get 104 gold, but then he collects 11, and then stops and says non satis
Here is my code:

# You need exactly 104 gold. 

less = "Nimis"
more = "Non satis"
requiredGold = 104

# This function calculates the sum of all coin values.
def sumCoinValues(coins):
    coinIndex = 0
    totalValue = 0
    # Iterate all coins.
    while coinIndex < len(coins):
        totalValue += coins[coinIndex].value
        coinIndex += 1
    return totalValue

def collectAllCoins():
    item = hero.findNearest(hero.findItems())
    while item:
        hero.moveXY(item.pos.x, item.pos.y)
        item = hero.findNearest(hero.findItems())

while True:
    items = hero.findItems()
    # Get the total value of coins.
    goldAmount = sumCoinValues(items)
    # If there are coins, then goldAmount isn't zero.
    if goldAmount != 0:
        # If goldAmount is less than requiredGold
        if goldAmount < requiredGold:
            # Then say "Non satis".
            hero.say("Non satis")
            # If goldAmount is greater than requiredGold
        if goldAmount > requiredGold:
            # Then say "Nimis".
            hero.say("Nimis")
            # If goldAmount is exactly equal to requiredGold
        if goldAmount == requiredGold:
            # Then collect all coins:
            coin = hero.findNearestItem()
            hero.moveXY(coin.pos.x, coin.pos.y)
        pass

Welcome to the discourse @_D_D! But sadly I do not know how to code in python. Hopefully someone will come help you!

try putting a break after you find 104 gold then use a while true loop outside the main loop to pick up the coins(try using the function you made to save lines of code and typing)

2 Likes

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