[SOLVED] Cloud Drip Commander

I’ve gotten to cloudrip Commander and got a boss star and I do what it says to do but then when he commands the first one he goes off to the X and just stays there 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 True:
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})
    soilderIndex = soldierIndex + 1
    

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

You spelled the soldierIndex wrong and you don’t need this part in front.

1 Like

Maybe you have to put these parts to While True Loop?

1 Like

And I think you have to write if soldier.

1 Like

i tried doing putting it in the while true loop it gets an error saying undefined of undefined and I delete the soldier index and then it says soldier is not defined which then I knew that was not going to work I out it back and replaced the while true loop with a if soldier and it does not work it does not command anyone so I dono what to do

Ah, sorry you don’t have to put it in a while. I think you have to write:
while soldierIndex < len(soldiers):, instead of
while True:

2 Likes

still only commands one guy I did not mean to hit solution

You have to write:

soldierIndex += 1

instead

of

Whats your updated code?

still commands one guy

So what’s your new code?


# 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 soldierIndex < len(soldiers):
    soldier = soldiers[soldierIndex]
    hero.command(soldier, "move", {"x": 50, "y": 40})
    soldierIndex + 1
    

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

You have to write soldierIndex += 1

I did it thanks (2000000000)

1 Like

Congratulations! I’m glad I could help! :partying_face:

Congrats on completing the level.

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