super sorry for the continous posting i’ll try not to any more
if goldAmount != 0:
# If goldAmount is less than requiredGold
if goldAmount < requiredGold:
# Then say "Non satis".
hero.say("Non statis")
# 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:
hero.say("all done")
pass
# 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(item)
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 statis")
# 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:
hero.say("all done")
pass
With what little I can see from your post, it looks like you have called the function properly. I’m not going to tell you where the typo is for a good reason. Many times you will find yourself combing through a bazillion lines of code just to find an error. You need to learn to do this. A friend of mine once spent 6 hours going through a huge section of code he wrote to debug it. He finally found the problem and it was a comma where a period should have been. Line by line, word by word. It’s part of programming. You’ll find it. Just go slow and look at every word individually.