Odd (Vector?) error on Broken circle level

While doing this level with vectors, I was getting a “TypeDef error, a.copy() is not a function” when running the below code. The error appeared on the Vector.subtract line. I also tried these but kept getting same error:
a) center = {“x”: 68, “y”: 68}; outside the function
b) "Vector.subtract(center,hero.pos)"
c) “def closerPos(pos)” and passing it hero.pos.

Any one know what the problem is?

def closerPos():
    #find a pos in a straight line between you and treasure
    # as close as possible before coming in range of a mine.
    #if there is a spot 10 units closer, report it, else, report None;
    pos = {'x':hero.pos.x,'y':hero.pos.y};
    center = {"x": 68, "y": 68};
    hero.say(pos); #here to debug and it does work saying {'x':136, 'y':67.95}
    hv = Vector.subtract(center,pos);
    hv = Vector.normalize(hv);
    hv = Vector.scale(hv,radiusStep);
    point = Vector.add(hv,pos);
    if hero.isPathClear(pos,point):
        return point;
    return None;

center is not a Vector, you need to convert it to the vector if you want to operate with it that way.

oh, wait ,why then is “center = {“x”: 68, “y”: 68};” what is provided in the level? Duh to my self, so this level doesn’t need to use vector. Thanks for answering.

Edit: Curiosity question: so how come the second argument to Vector.subtract can be any object with an x and y, but not the first argument? That seems a bit weird. This seems like something that should appear in the pop up when you hover over vector in the menu below one’s code so people new to vector can understand its requirements.

As you want. Vectors can be useful here, but you can solve it without them.

Your answer is here. As you can see that method doesn’t check the type of the second argument, just x and y properties.

Ah, now that error message makes sense, though this is definitely a programming hazard. I hope the notes to players get updated, or the Vector class is made more robust.