The Two Flowers new problem. Help please[SOLVED]

Hi all, i 'm getting an error telling me that something is undefined but i thought i had defined it.

here it is.
CodeCombat - Coding games to learn Python and JavaScript? Two Flowers link.

# If the peasant is damaged, the flowers will shrink!

def summonSoldiers():
    if hero.gold >= hero.costOf("soldier"):
        hero.summon("soldier")

# Define the function: commandSoldiers
def commandSoldiers():
    for soldier in hero.findFriends():
        enemy = hero.findNearestEnemy()
        if soldier.type == "soldier":
            peasant = hero.findByType("peasant")[0]
            if enemy:
                hero.command(soldier, "defend", peasant.pos.x, peasant.pos.y)
# Define the function: pickUpNearestCoin
def pickUpNearestCoin():
    items = hero.findItems()
    nearestCoin = hero.findNearestItem()
    if nearestCoin:
        hero.move(nearestCoin.pos)
            

while True:
    summonSoldiers()
    commandSoldiers()
    pickUpNearestCoin()

arent i defining peasant by with this? >>> peasant = hero.findByType("peasant")[0]

No need to create two topics of the same problem, can someone close this?
Lydia

if you read the bottom two comments of the other topic you will see that i was asked to end the other topic and create a new one if had another problem.

in the meantime while a decision is made about this would you be able to help me please?

If it is on the same level then go ahead and post it on the other topic else create a new one @Psyko2k.

1 Like

thank you, i’ve literally just solved it. took forever but hey :smiley:

1 Like

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