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.
Try to put all your “if’s” to big “if enemy:” And try to answer a question:
You can get some gems.
So what should I do to fix it then.
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
BTw, again it was what I said.
Oops… sorry, I usually just focus on the person/people who are having trouble with the level.
Lydia
@Zoe_Witte have you completed the level?
Andrei
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.
So you solved it? Congratulations!
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.
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.
Oh, ok. Then congratulations! Then let’s mark the topic as solved.
Andrei