Play Home Contribute Github Join Us! Discourse Staff Members Github Contribution Guides Team

Unknown Uadd operator bug?

So i am in the Basin Stampede lvl and this “Unknown Uadd Operator” error pops up and i dont know what to do becurse its right coded.
here is the code (im using python)

while True:
enemy = hero.findNearestEnemy()
xPos = hero.pos.x + 5
yPos = 17
if enemy:
# Adjust y up or down to get away from yaks.
if enemy.pos.y > hero.pos.y:
# If the Yak is above you, subtract 3 from yPos.
yPos = -3
pass
elif enemy.pos.y < hero.pos.y:
# If the Yak is below you, add 3 to yPos.
yPos = +3
pass
hero.moveXY(xPos, yPos)`

Firstly, please remember to properly format your code: [Essentials] How To Post/Format Your Code Correctly

Second, you are setting yPos to a hard ‘-3’, not subtracting 3 from the current value of yPos. Similar issue with the add to yPos statement. Fix those and I think you’ve got it :slight_smile:

Oh…it’s not a bug either.

1 Like

Hi.

Looks like smthng wrong with your + operation)
I changed yPos = +3 and yPos = -3 to yPos = yPos +3 and yPos =yPos -3, and it worked fine.
Good luck!)

Oh, I`m late))
Besides, it’s funny, but with broken code yaks do all the job for player)

1 Like

I used += 3 and -= 3, cuz I hate unneeded typeing … but I don’t like typing to begin with :smiley:

1 Like