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 Likes

change the line for buildXY coordinates for x, y

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

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

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)

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