New error in sarvan treasure[SOLVED]

I was playing sarvan treasure when it gave me this error

if enemy:
        if item and hero.distanceTo(item) < enemy.pos:

ps that is just a little bit of my code but the error was on the if item line

1 Like

I guess I fixed. I changed enemy.pos to enemy.distanceTo(item)

1 Like

In case you’re wondering, that error is because you can’t compare two values of a different data type with the an operator like >, < <= >= etc.
It’s like saying:

if "cheese" < 56:
    hero.say("This will never run..(and will cause an error)")

The value on the error {x: 43.75, y: 38.52, z: 2.00} is the enemy.pos. Position comes with x, y and z (which is how far up in the air something is (I think). It’s only relevant when you get blown sky high by mines.). And hero.distanceTo(item) is just an integer (or maybe a float, that’s a number with decimal places, whereas an integer is a whole number).
You may have already realised that, but I just wanted to tell you why the error happened.


Oh okay thanks for explaining.

1 Like

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.