Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Help me please i am super stuck and about to rage

friends = hero.findFriends()
for friend in friends:
        # Practice using modulo to loop over an array
    # Choose the mix and order of units you want to summon by populating this array:
    summonTypes = ["soldier", "archer"]
    
    def summonTroops():
        # Use % to wrap around the summonTypes array based on len(hero.built)
        #type = summonTypes[???]
        soldier = summonTypes["soldier"]
        archer = summonTypes["archer"]
        len(hero.built) % len(summonTypes)
    
    def collectCoins():
        coin = hero.findNearestItem()
        if coin:
            hero.move(coin.pos)
    
    def commandTroops():
        enemy = hero.findNearestEnemy()
        if enemy:
            hero.summon(soldier, "attack", enemy)
            hero.summon(soldier, "attack", enemy)
        else:
            hero.summon(soldier, "defend", hero.pos)
            hero.summon(archer, "defend", hero.pos)
    while True:
        summonTroops()
        collectCoins()
        commandTroops()

here is the error i am getting
image

Please stick to one topic, I’ve said this too many times…


Thanks
Danny

Read hints??? Hints help you alot.