Vital Powers Help plz

I need help with my code and there are no errors.
My code:

# This level shows how to define your own functions.
# The code inside a function is not executed immediately. It's saved for later.
# This function has your hero collect the nearest coin.
def pickUpNearestCoin():
    items = self.findItems()
    nearestCoin = self.findNearest(items)
    if nearestCoin:
        self.move(nearestCoin.pos)

# This function has your hero summon a soldier.
def summonSoldier():
    # Fill in code here to summon a soldier if you have enough gold.
    while self.gold > self.costOf("soldier"):
        self.summon("soldier")
    for soilder in soilders:
        if enemy:
            self.command(soilder, "attack", enemy)
    pass


# This function commands your soldiers to attack their nearest enemy.
def commandSoldiers():
    for soldier in self.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            self.command(soldier, "attack", enemy)

loop:
    # In your loop, you can "call" the functions defined above.
    # The following line causes the code inside the "pickUpNearestCoin" function to be executed.
    pickUpNearestCoin()
    # Call summonSoldier here
    summonSoldier
    # Call commandSoldiers her
  1. summonSoldier is a function, you need to call it like this:
summonSolider()
  1. You are not calling commandSoldiers() at all in your loop

  2. Leaving sumonSolider like this in your code will definitely produce an error. Run the cod,e you’ll see an red X under the hero. The look on the right for market line where the error appears.

not solider
its soldier

what gear do you have
i recommend a speed ring and good armor i had 3400 health
i did not even have to write a code and i solved it

plus you dont need to do pickup nearest coin at the end
define enemy
define soilder

actually you do need to do pickupNearest at the end but just add commandSoldier() at the end

Thanks for the advice.

What do you mean??:open_mouth:

This is my code and there is a red X mark under my hero.

# This level shows how to define your own functions.
# The code inside a function is not executed immediately. It's saved for later.
# This function has your hero collect the nearest
enemy = self.findEnemies()
soilder = self.findFriends()
def pickUpNearestCoin():
    items = self.findItems()
    nearestCoin = self.findNearest(items)
    if nearestCoin:
        self.move(nearestCoin.pos)

# This function has your hero summon a soldier.
def summonSoldier():
    # Fill in code here to summon a soldier if you have enough gold.
    while self.gold > self.costOf("soldier"):
        self.summon("soldier")
    for soilder in soilders:
        if enemy:
            self.command(soilder, "attack", enemy)
    pass


# This function commands your soldiers to attack their nearest enemy.
def commandSoldiers():
    for soldier in self.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            self.command(soldier, "attack", enemy)

loop:
    self.summon("soldier")
    self.command(soilder, "attack", enemy)
    # In your loop, you can "call" the functions defined above.
    # The following line causes the code inside the "pickUpNearestCoin" function to be executed.
    pickUpNearestCoin()
    # Call summonSoldier here
    summonSoldier()
    # Call commandSoldiers here
    commandSoilders()

just take out
at the bottom

self.summon("soldier")
and also
self.command(soilder, "attack", enemy)

like this

loop:
    # In your loop, you can "call" the functions defined above.
    # The following line causes the code inside the "pickUpNearestCoin" function to be executed.
    pickUpNearestCoin()
    # Call summonSoldier here
    summonSoldier()
    # Call commandSoldiers her
    commandSoldiers()

at the end

It still does not work.

## This function has your hero summons
def summonSoldier():
    # Fill in code here to summon a soldier if you have enough gold.
    while self.gold > self.costOf("soldier"):
        self.summon("soldier")
    for soilder in soilders:
        if enemy:
            self.command(soilder, "attack", enemy)
    pass


# This function commands your soldiers to attack their nearest enemy.
def commandSoldiers():
    for soldier in self.findFriends():
        enemy = soldier.findNearestEnemy()
        if enemy:
            self.command(soldier, "attack", enemy)

loop:
    # In your loop, you can "call" the functions defined above.
    # The following line causes the code inside the "pickUpNearestCoin" function to be executed.
    pickUpNearestCoin()
    # Call summonSoldier here
    summonSoldier()
    # Call commandSoldiers here
    commandSoldiers()

It says pick up nearest coin is not defined

Thanks for the advice though.

Nvm I beat it
Thx
Yay

I have the same problem he does but mine still says pickup nearest coin is not defined.

can anyone help me i dont know what to do

Hi @lundyundy and welcome to the forum!

Please post your code, properly formatted, so we can see what’s going on. This link will show you how to do this: [Essentials] How To Post/Format Your Code Correctly

im sorry i figured it out but could anyone help me with summits gate ? this is my code.

 Fight your way into the Inner Sanctum of the ogre chieftain, and kill her.
def commandPaladin():
    for paladin in paladins: 
        down = {"x": paladin.pos.x, "y": paladin.pos.y - 40}
        if hero.health <= 300:
            hero.command(paladin, "cast", "heal", hero)
        elif enemy:
            hero.command(paladin, "attack", enemy)
        else:
            hero.command(paladin, "move", down)
            if enemy:
                hero.command(paladin, "attack", enemy)
            else:
                hero.command(paladin, "move", down)
def commandSoldiers(friend):
    for friend in friends:
        if enemy and enemy.type is "catapult":
            hero.command(friend, "attack", enemy)
        elif enemy:
            hero.command(friend, "attack", enemy)
def commandArchers(friend):
    for friend in friends:
        if enemy:
            hero.command(friend, "attack", enemy)
def commandFriends():
    if friend and friend.type == "soldier":
        commandSoldiers(friend)
    if friend and friend.type == "paladin":
        commandPaladin()
    if friend and friend.type == "archer":
        commandArchers(friend)
def flagFunction(flag):
    if flag and enemy:
        hero.jumpTo(flag)
        hero.pickUpFlag(flag)
    elif flag:
        hero.pickUpFlag(flag)
def commandHero(hero):
    if friend and enemy and enemy.type == "warlock":
            hero.command(friend, "attack", heroEnemy)
    elif heroEnemy and heroEnemy.type == "tower":
        hero.attack(heroEnemy)
    elif heroEnemy:
        if hero.isReady("stomp"):
            hero.stomp()
        elif hero.isReady("throw"):
            hero.throw(heroEnemy)
        elif heroEnemy:
            hero.attack(heroEnemy)
    else:
        hero.moveXY(hero.pos.x, hero.pos.y - 20)
        elif heroEnemy:
            hero.attack(heroEnemy)
        else:
            hero.moveXY(hero.pos.x, hero.pos.y + 10)
    
loop:
    friends = hero.findFriends()
    friend = hero.findNearest(friends)
    paladins = hero.findByType("paladin")
    enemy = friend.findNearest(friend.findEnemies())
    heroEnemy = hero.findNearest(hero.findEnemies())
    flag = hero.findFlag("violet")
    commandFriends()
    flagFunction(flag)
    commandHero(hero)