Weird bug on Goalkeeper


Using the following code, I’m getting an “Unhandled error: distance’s argument target has a problem. Find the distance to a target unit.” a little ways in.

ball = hero.findNearest(hero.findByType("ball"))
peasants = hero.findByType("peasant")

while True:
    if ball.pos.x < 26:
        while ball.pos.x < 26:
            hero.command(peasants[0], "move", {"x": 19, "y": ball.pos.y+1})
            hero.command(peasants[1], "move", {"x": 19, "y": ball.pos.y-1})
    hero.command(peasants[0], "move", {"x": 19, "y": 40})
    hero.command(peasants[1], "move", {"x": 19, "y": 32})

As you can see, I’m not even using distanceTo in my code! Any ideas why this error might be happening?
Screenshot -


Wierd, does fixing the formatting in the else statement help at all? You should be getting an error for that, perhaps it is displaying the wromg message.


Try to put ball = hero.findNearest(hero.findByType(“ball”)) inside While True:
and change if ball.pos.x < 26: to if ball and ball.pos.x < 26:


Tried the exact same code again today and it worked fine, no errors. Although Hinkle you’re right, I should be getting an error for my spacing in the else statement. Weird.