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

Cloudrip Commander lvl help

# 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
# Add a while loop to command all the soldiers.
while hero.command("move"):
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})

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

With the while loop you’ve got to do it like you did in earlier desert levels: using len(soldiers) and soldierIndex. I think you maybe think it’s more complicated than it actually is.
Danny

Well the only problem is, Their own code that they inputted isnt working so.

Is what you’ve posted the starting code?

No, It is the starter code, but i added some parts.

My starter code doesn’t have any errors:

# 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
# Add a while loop to command all the soldiers.

soldier = soldiers[soldierIndex]
hero.command(soldier, "move", {"x": 50, "y": 40})

# Go join your comrades!

If that’s what yours looks like, then what are you having trouble with?
Danny

There are two issues that I see with your original code. @Deadpool198 mentioned the first one with the while loop not set up correctly. You do have to indent the two lines after it that weren’t originally indented in the startup code.

Also, the command to move your hero isn’t quite correct.