Can't solve Interception

I’m supposed to be in between my friends and the enemy, but the game keep saying the friends property is protected.

Here is my code:
while True: enemy = hero.findNearestEnemy() friend = self.findFriends hero.moveXY(enemy.pos.x - friend.pos.x, enemy.pos.y - friend.pos.y)

2 Likes

You are not calling the function findFriends. You are simply pointing to the location of the function, which, doesn’t have the property pos.

Try this instead:

friend = hero.findNearest(hero.findFriends())
4 Likes

Hi
I tried this but look what happened:


Anything anyone can suggest, or is it just a problem with the game?

1 Like

You probably need better glasses.

The error message could be improved, though.

2 Likes

Thanks, yeah, I only had wooden glasses.

1 Like

my hero just runs away for some reason when I used the code @Angelblade as well as the code from @Serg

:confounded:

1 Like

right now I am using the ‘Enchanted Lenses’ so it cant be my glasses… :persevere:

1 Like

Your code needs to be inside the while-true loop. Review basics on indentation and then come back. :slightly_smiling_face:

1 Like

Please review the instructions. The commented out code tells you what to do. Here they are in case you accidentally deleted them:

    // Calculate x by adding friend.pos.x to enemy.pos.x
    // Then divide by 2.
    // Check the guide if you need more help!

    // Now do the same for y
    // Move to the x and y coordinates you calculated.

If you still need help, look in the Hints or ask me.

1 Like

please tell me what is wrong i want to beat this level
while True:
billy= hero.findEnemies()
steve = hero.findFriends()
enemy = hero.findNearest(billy)
friend = hero.findNearest(steve)
enemy.pos.x == enemy.x
friend.pos.x == friend.x
enemy.pos.y == enemy.y
friend.pos.y == friend.y
# Calculate x by adding friend.pos.x to enemy.pos.x
# Then divide by 2.
# Check the guide if you need more help!
1 == (enemy.pos.x + friend.pos.x) / 2
# Now do the same for y
2 == (enemy.pos.y + friend.pos.y) / 2
# Move to the x and y coordinates you calculated.
hero.moveXY(1 , 2 )

format your code correctly.

please format you code according to the FAQ, which can be found in here: FAQ - Check Before Posting

and i think i found the problem in your code instead of naming your variables 1 and 2, name them x and y, because when you put 1 or 2 in the moveXY command, it thinks that you mean 1 and 2 as numbers, not as variables