decoysBuilt = 0
while True:
coin = hero.findNearestItem()
if coin:
# Collect the coin!
hero.moveXY(coin.pos.x, coin.pos.y)
pass
# Each decoy costs 25 gold.
# If hero.gold is greater than or equal to 25:
if hero.gold <= 25:
# buildXY a "decoy"
hero.buildXY("decoy", x, y)
# Add 1 to the decoysBuilt count.
decoysBuilt += 1
if decoysBuilt == 4:
# Break out of the loop when you have built 4.
break
pass
hero.say(“Done building decoys!”)
hero.moveXY(14, 36)
At the first sight - I’m not sure that you really want to type
# If hero.gold is greater than or equal to 25:
if hero.gold <= 25:
# buildXY a "decoy"
hero.buildXY("decoy", x, y)
# Add 1 to the decoysBuilt count.
decoysBuilt += 1
Comments are important as far as they are a part of level instructions.
Nope.
Your expression if hero.gold <= 25: literally means that hero.gold is less or equal 25.|
And hero.say(“Done building decoys!”) should be changed somehow. You don’t need to say “Done building decoys!” or put hero.say(“4”). decoysBuilt is variable that stores the quantity. Put it to the command hero.say