while True:
enemy = hero.findNearestEnemy()
# With AND, the type is only checked if enemy exists.
if enemy and enemy.type == "munchkin":
hero.attack(enemy);
# Find the nearest item.
item = hero.findNearestItem()
# Collect item if it exists and its type is "coin".
if item.type == "coin":
hero.moveXY (item.pos.x, item.pos.y);
What’s your problem?
Kifyu
The x = item.pos.x
and y = item.pos.y
need to be before hero.moveXY(x,y)
For me, the code will work well!? That’s why I don’t understand???
Which world is this in?
I’m on an ipad so I can’t get to the levels. I might not have even done that level.
lol !!!
20 car cake plz
while True:
enemy = hero.findNearestEnemy()
# With AND, the type is only checked if enemy exists.
if enemy and enemy.type == "munchkin":
hero.attack(enemy)
# Find the nearest item.
item = hero.findNearestItem()
#Move to the position of the item.
if item.type == "coin":
hero.moveXY (item.pos.x, item.pos.y)
# Collect item if it exists and its type is "coin"
you may have forgotten the:
if item and item.type == "coin":
does it work now? 200
This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.