[SOLVED] Endangered Burl!

while True:
    enemy = hero.findNearestEnemy()
    
    # Remember: don't attack type "burl"!
    if enemy.type == "burl":
        hero.say("I am not attacking that Burl")
    
    # The "type" property tells you what kind of creature it is.
    if enemy.type == "munchkin":
        hero.attack(enemy)
        
    
    # Use "if" to attack a "thrower".
    if enemy.type == "thrower":
        hero.attack(enemy)
        
        # If it's an "ogre", use moveXY to run away to the village gate!
        if enemy.type is "ogre":
            hero.moveXY(41, 47)

Right now, you are saying if there’s a thrower and there’s a ogre, then move.

1 Like

Try to put all your “if’s” to big “if enemy:” And try to answer a question:
изображение
You can get some gems. :wink:

So what should I do to fix it then.

1 Like

Oh…
I think you gotta put this @Zoe_Witte

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
         if enemy.type == "burl":
               all that stuff.
         if enemy.type == "munchkin":
               blah blah blah
        if enemy.type == "thrower":
               you know what to do
       if enemy.type is "ogre":
               move somewhere.

Lydia

1 Like

BTw, again it was what I said. :grinning:

1 Like

Oops… sorry, I usually just focus on the person/people who are having trouble with the level.
:sweat_smile: :stuck_out_tongue:
Lydia

2 Likes

@Zoe_Witte have you completed the level?

Andrei

1 Like

It shows me dying instead of running away from the ogre.

while True:
    enemy = hero.findNearestEnemy()
    
    # Remember: don't attack type "burl"!
    if enemy.type == "burl":
        hero.say("I am not attacking that Burl")
    
    # The "type" property tells you what kind of creature it is.
    if enemy.type == "munchkin":
        hero.attack(enemy)
        
    
    # Use "if" to attack a "thrower".
    if enemy.type == "thrower":
        hero.attack(enemy)
        
        # If it's an "ogre", use moveXY to run away to the village gate!
        if enemy.type is "ogre":
            hero.moveXY(21, 41)

You have to put all stuff like if enemy.type == "burl": in BIG if enemy:

So I have to make it all under one if enemy

Yeah like:

enemy = hero.findNearestEnemy()
    if enemy:
       # Remember: don't attack type "burl"!
       if enemy.type == "burl":
           hero.say("I am not attacking that Burl")
       and all other ifs

It is under one if enemy: but it’s still not working.

It worked after I removed all the spaces in between each command.

1 Like

So you solved it? Congratulations! :partying_face:

1 Like

Yes I did thank you so much because this is my first time trying out coding and my brother got me interested in it as well.

2 Likes

Why do you only execute this if there is also a thrower? This might be your error.

Andrei

No it was the spaces and I beat it.

1 Like

Oh, ok. Then congratulations! Then let’s mark the topic as solved. :partying_face:

Andrei

2 Likes