Error on Interception! Please help!

I’m having trouble on Interception. Here’s my code:

def mid(a,b):
    newX = (a.pos.x + b.pos.x) / 2
    newY = (a.pos.y + b.pos.y) / 2
    pass
while True:
    enemy = hero.findNearestEnemy()
    friend = hero.findNearestFriend()
    hero.targetPos = mid(enemy,friend)
    hero.moveXY(hero.targetPos.x, hero.targetPos.y)
    pass

All it tells me is “TypeError: Cannot read property ‘realm’ of undefined” and then it highlights (a.pos.y + b.pos.y) in line 3.

hero.targetPos = mid(enemy,friend) I dont know what your doing but this is not a valid statement.

Edit: This is not valid hero.targetPos =

hero.targetPos should not be before the = sign.

I guess I should explain that the (.) Is reserved for methods.

I defined that function in the code.

Sorry. I saved up my gems for the sapphire sense stone, which offers that function.

Im not saying you cant use it. You just cant be using it before the = sign. Thats a method from the sapphire stone its not a variable to be holding a number.

I just want to point out this does not work for 2 reasons. hero.targetPos = mid(enemy,friend)

hero.targetPos can not be assigned to hold a value.
mid(enemy,friend) This method is fine except that it doesnt return anything. It looks like you want use this return value as an object. You need to return an object holding the two new variables.

This can work if you replace the period with _ or nothing have the words touching. Then have your Mid function return an object.

Im just guessing but chances are your error is because your variables dont hold a value when passed. You should check to see if theirs an enemy and a friend before using your function.