{Backwoods Forest} - Help with Friend and foes


#21

Is this Javascript? And is this the exact piece of code.


#22

no (20 characters is annoying)


#23

How do we know their id?


#24

So in this level, use

enemy=hero.findNearestEnemy()

to find the enemy.
Then to find their id, just do:
id=enemy.id.


#25

while True:
    friend = hero.findNearestFriend()
    if friend:
        hero.say("To battle, " + friend.id + "!")
    # Now find the nearest enemy and tell them to go away.
    hero.findNearestEnemy()
    if enemy:
        enemy    =    hero.findNearestEnemy()
        # What do I put here on this line?

What do I put on that line


#26

And the ogres names are peon.


#27

Put the enemy = hero.findNearestEnemy() OUT of the if enemy:. You are defining the enemy after stating it. The computer will not know what “enemy” is until you define it. That’s why if enemy: enemy = hero.findNearestEnemy() will not work.