It keeps saying that item.pos should be hero.pos but it shouldn’t be.
while True:
item = hero.findNearestItem()
if hero.health < hero.maxHealth/3:
hero.say("Something")
pass
if item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x+8, hero.pos.y)
pass
if item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y+8)
pass
Screenshot of Error:
I got rid of the pass but it still won’t work…
do if not item: break
before the health check, and do else if
for the x and y stuff
@A.Lee452 does it work now
My code now (still doesn’t work):
while True:
item = hero.findNearestItem()
if not item:
break
if hero.health < hero.maxHealth/3:
hero.say("Something")
if item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x+8, hero.pos.y)
else:
hero.moveXY(hero.pos.x-8, hero.pos.y)
if item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y+8)
else:
hero.moveXY(hero.pos.x, hero.pos.y-8)
no, that’s not what I mean, instead of if
, put elif
, no else
sorry that I keep @ing you, buttttttttttt, @A.Lee452
Code Now(the hero won’t move up only right):
while True:
item = hero.findNearestItem()
if not item:
break
elif hero.health < hero.maxHealth/3:
hero.say("Something")
elif item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x+8, hero.pos.y)
elif item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y+8)
The hero still won’t move up:
while True:
item = hero.findNearestItem()
if not item:
break
if hero.health < hero.maxHealth/3:
hero.say("Something")
elif item.pos.y > hero.pos.y:
hero.moveXY(hero.pos.x, hero.pos.y+8)
elif item.pos.x > hero.pos.x:
hero.moveXY(hero.pos.x+8, hero.pos.y)
get a faster hero? idk, mine works fine with that exact code
I can’t change the hero it’s automatically assigned to me bc I have Hattori but it’s using Anya
you in a class or something?
Yeah I already asked the teacher for help and he doesn’t know
fuery
April 18, 2023, 5:43pm
20
It might be to do with your hero’s vision. There may not be any nearby items in sight when the error occurs, so item
is empty (None or null as stated in the error), so I believe that is the source of your error. I may be incorrect, but this is the best guess I have. Real quick, what glasses item do you have equipped?