[SOLVED] Return To Thornbrush Farm: please help!


#1

Could someone help me on Return to Thornbrush Farm? I keep killing a villager that I’m not supposed to kill. Here’s the code: # The function maybeBuildTrap defines TWO parameters!
def maybeBuildTrap(x, y):
# Use x and y as the coordinates to move to.
hero.moveXY(x, y)
enemy = hero.findNearestEnemy()
if enemy:
pass
# Use buildXY to build a “fire-trap” at the given x and y.
hero.buildXY(“fire-trap”, 43, 50)
while True:
# This calls maybeBuildTrap, with the coordinates of the top entrance.
maybeBuildTrap(43, 50)

# Now use maybeBuildTrap at the left entrance!
maybeBuildTrap(25,34)
# Now use maybeBuildTrap at the bottom entrance!
maybeBuildTrap(43,20)

#2


#3

Please format your code correctly.


#4

change the line for buildXY coordinates for x, y


#5

I keep blowing up one of the villagers at the left entrance. That’s the big problem.


#6

change the first build “fire-trap” with x,y


#7

I type in this : hero.buildXY(x,y) for the if enemy statement. Here’s my code:

The function maybeBuildTrap defines TWO parameters!

def maybeBuildTrap(x, y):
# Use x and y as the coordinates to move to.
hero.moveXY(x, y)
enemy = hero.findNearestEnemy()
if enemy:
pass
# Use buildXY to build a “fire-trap” at the given x and y.
hero.buildXY(x,y)
while True:
# This calls maybeBuildTrap, with the coordinates of the top entrance.
maybeBuildTrap(43, 50)

# Now use maybeBuildTrap at the left entrance!
maybeBuildTrap(25,34)
# Now use maybeBuildTrap at the bottom entrance!
maybeBUildTrap(43,20)

#8

Oh! Silly me… I forgot to put the “fire-trap” inside the parenthesis of the buildXY function. Thanks! Now I have passed the level!