I’m not sure what’s going wrong with this code exactly, there’s a problem with line 12. It says “command’s argument minion should have type unit, but got object: Hector.”
# 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():
for soldier in hero.findFriends():
enemy = soldier.findNearestEnemy()
if enemy:
hero.command(soldier, "attack", enemy)
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
item = hero.findItems()
nearestCoin = hero.findNearest(item)
if nearestCoin:
hero.move(nearestCoin.pos)
peasant = hero.findByType("peasant")[0]
while True:
summonSoldiers()
# commandSoldiers()
# pickUpNearestCoin()
commandSoldiers()
pickUpNearestCoin()
Any help is greatly appreciated!