Mountain Mecernaries Assistance

# Gather coins to summon soldiers and have them attack the enemy.
while True:
    hero.findNearestItem()
    coin = NearestItem
    # Move to the nearest coin.
    # Use move instead of moveXY so you can command constantly.
    if coin:
        hero.move(coin.pos.x) (coin.pos.y)    
        hero.say("I need coins!")
    # If you have funds for a soldier, summon one.
    if hero.gold > hero.costOf("soldier"):
        hero.say("I should summon something here!")
        hero.summon("soldier")
    enemy = hero.findNearest(hero.findEnemies())
    if enemy:
        soldiers = hero.findFriends()
        soldierIndex = 0
        soldier = soldiers[soldierIndex]
        # Loop over all your soldiers and order them to attack.
        while True:
            # Use the 'attack' command to make your soldiers attack
            hero.command(soldier, "attack", enemy)
            #hero.command(soldier, "attack", enemy)

So using this Python code gives me
image
but if I remove line 4 it gives me
image
and i’m really confused on what to do to fix it.

This should be one statement

1 Like

Was the problem solved @RiceRunner ?

Sorry I’ve been busy ill try it later

Like this?
Sorry i’ve been busy with school and homework recently

No, make this first statement a variable, variable = hero.something

Hint (think about it first)

Try another time before this! → coin = hero.findNearestItem()

Would it be
coin = hero.findNearestItem?
I’d put that at the start right?
I haven’t checked the hint yet incase i’m wrong

That’s right, but don’t forget the parenthesis, and yes at the top, though inside the while True loop

while True:
    coin = hero.findNearestItem()
    # Move to the nearest coin.
    # Use move instead of moveXY so you can command constantly.
    if coin:
        hero.move(coin.pos.x) (coin.pos.y)

Apparantly there’s something wrong on the last line

This statement takes only one parameter, and i doubt that there is any method that takes more than one pair of parenthesis.
You can either do: hero.move(coin.pos)
or hero.moveXY(coin.posx, coin.pos.y)

Cool, i’ve got an english assessment rn, so ill try it later