So I am playing the peek-a-boom level as a wizard that has way too good eye site so the code looks like this.
while True:
enemy = hero.findNearestEnemy()
if enemy:
# Build a "fire-trap" at the Red X (41, 24)
hero.buildXY("fire-trap", 41, 24)
hero.moveXY(19, 19)
#these are to move the hero back because for some reason the hero slides off the wooden x
hero.moveXY(19, 19)
hero.moveXY(19, 19)
hero.wait(7)
#the wait is to stop it from going back to the red x over and over again.
# Add an else below to move back to the clearing
else:
# Move to the Wooden X (19, 19)
hero.moveXY(19, 19)
The weird thing that even though the trap is there and the hero moves back (maybe too quickly but I am not sure) the munchkin turns around and attacks an on coming villager or goes though the crack.