Geez this is weird


Return to thornbush farm
Every time i run the code it see friendly’s as enemy’s as enemy’s i even programed it to see friendly but it said that 1 friendly was a enemy, please help!


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()
friend = hero.findNearestFriend()
if enemy:
# Use buildXY to build a “fire-trap” at the given x and y.
hero.buildXY(“fire-trap”, 36, 30)
while True:
# This calls maybeBuildTrap, with the coordinates of the top entrance.
maybeBuildTrap(43, 50)
# Now use maybeBuildTrap at the left entrance!
maybeBuildTrap(25, 35)
# Now use maybeBuildTrap at the bottom entrance!
maybeBuildTrap(42, 20)


Please learn to post your code properly. It’s really easy and only requires a very small amount of effort.

To post your code from the game, use the </> button or it won’t format properly. When you click the </> button, the following will appear:

Please paste ALL of your code inside the triple back tick marks.

``` <— Triple back tick marks.

Paste ALL of your code in here.

``` <— Triple back tick marks.

There are many people here willing and able to help. If you use the </> button correctly, then ALL of your code should look like this:

while True:
    enemy = hero.findNearestEnemy()
    if enemy:
        hero.say("My code is formatted properly")

If ALL of your code isn’t formatted like the code above, then you’re doing it wrong and we can’t see the structure of the code to troubleshoot whether or not that is the issue. Use the </> button and help us help you. This works when sending a private message as well.

Thank you.


you said pass. you also said hero.buildXY(“fire-trap”, 36, 30). you should have put in x and y instead of 36 and 30, because otherwise, you would infinitely build a firetrap at 36,30.