When I run this code, all that happens is that I summon some soldiers with the gold I already have, and then I am frozen building something.
# Gather coins to summon soldiers and have them attack the enemy. while True: # Move to the nearest coin. # Use move instead of moveXY so you can command constantly. coins = hero.findNearest(hero.findItems()) coinIndex = 0 while coinIndex < len(coins): coin = coins[coinIndex] if coin: hero.move(coin.pos) coinIndex += 1 # If you have funds for a soldier, summon one. if hero.gold > hero.costOf("soldier"): hero.summon("soldier") enemy = hero.findNearest(hero.findEnemies()) soldiers = hero.findFriends() soldierIndex = 0 while soldierIndex < len(soldiers): soldier = soldiers[soldierIndex] if enemy: hero.command(soldier, "attack", enemy) soldierIndex += 1 # Use the 'attack' command to make your soldiers attack. #hero.command(soldier, "attack", enemy)