Help Cloudrip Commander[SOLVED]

# Summon some soldiers, then direct them to your base.

# Each soldier costs 20 gold.
while hero.gold > hero.costOf("soldier"):
    hero.summon("soldier")
    
soldiers = hero.findFriends()
soldierIndex = 0
soldier = soldiers[soldierIndex]
# Add a while loop to command all the soldiers.
while True:
    
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})
    soldierIndex += 1
    

# Go join your comrades!
hero.moveXY(51, 41)

What ends up happening is when the last soldier moves and the soldierIndex is incremented one too many times, the game has an erroer telling me there is nothing to command.

:frowning: 20 charecters text

You are using a while True loop, so you will be forever incrementing soldierIndex. Replace with while soldierIndex < len(soldiers)

ahhh…
I had been trying

while soldierIndex < soldiers

lol umm yay thanks

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.