Check it out here. We created this level as a way to ramp up to the significantly harder Thornbush Farm. What we’re most interested in is whether this and Village Guard are a better way to introduce players to if/else than simply throwing people into Thornbush.
Hello guys, found bug on this level, take a look on a screen attached.
This level has a bug. For some reason the code below makes me attack the Burl.
loop:
enemy = self.findNearestEnemy()
if enemy.type is “ogre”:
self.moveXY(28, 47)
self.moveXY(20, 20)
elif enemy.type is “burl”:
self.say(“Nearest enemy is a burl.”)
else self.attack(enemy)
@Serhii_Hrabas Looks like 1) you need a colon after your line 15 and 2) we have a bug with our error messages! I’ve added this to our list.
@robert_peetsalu You should be getting an error message from your else
? It needs a colon after it, too. Although it shouldn’t be making you attack the burl, it’s probably breaking in some weird way from the invalid else
syntax.
loop:
enemy = self.findNearestEnemy()
# Remember: don't attack type "burl"!
if enemy.type is "burl":
self.say("I'm not attacking that Burl!")
# The "type" property tells you what kind of creature it is.
if enemy.type is "munchkin":
self.attack(enemy)
# Use "if" to attack a "thrower".
if enemy. type is "thrower":
self.attack("thrower")
# If it's an "ogre", run away to the village gate!
if enemy. type is "ogre":
self.moveXY(40, 47)
That looks good, except don’t put spaces in between enemy. type
. Just use enemy.type
.
is this good
loop:
enemy = self.findNearestEnemy()
# Remember: don't attack type "burl"!
if enemy.type is "burl":
self.say("I'm not attacking that Burl!")
# The "type" property tells you what kind of creature it is.
if enemy.type:"munchkin"
self.attack(enemy)
# Use "if" to attack a "thrower".
if enemy. type is "thrower":
self.attack("thrower")
# If it's an "ogre", run away to the village gate!
if enemy. type is "ogre":
self.moveXY(40, 47)
I used that but it says enemy is undefined?
All your code needs to be indented so that it’s part of the loop.
if enemy.type:"munchkin"
should have if enemy.type is "munchkin"
instead of the colon.
i have this and i indented but it still says error on line 2 undefined is not an action.
loop:
enemy = self.findNearestEnemy()
if enemy.type is "burl":
self.say('I am not attacking that Burl!')
if enemy.type is "munchkin":
self.attack(enemy)
if enemy.type is "thrower":
self.attack(enemy)
if enemy.type is 'ogre':
self.moveXY(41, 37)
enemy is also indented
You may not have glasses with findNearestEnemy
equipped?
Actually i used this. it was the correct answer