My code isn’t working… can someone look it over for me?
Code:
# If the peasant is damaged, the flowers will shrink!
def summonSoldiers():
if hero.gold >= hero.costOf("soldier"):
hero.summon("soldier")
# Define the function: commandSoldiers
def commandSoldiers():
soldiers = hero.findByType("soldier")
for soldier in soldiers:
enemies = soldier.findEnemies()
enemy = soldier.findNearestEnemy(enemies)
hero.command(soldier, "attack", enemy)
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
item = hero.findNearestItem()
if item:
hero.moveXY(item.pos.x,item.pos.y)
peasant = hero.findByType("peasant")[0]
while True:
summonSoldiers()
# commandSoldiers()
commandSoldiers()
# pickUpNearestCoin()
pickUpNearestCoin()