# Follow the trail of coins to the red X at the exit.
while True:
# This finds the nearest item.
item = hero.findNearestItem()
if item:
# This stores the item's pos, or position in a variable.
itemPosition = item.pos
# Put the X and Y coordinates of the item into variables.
itemX = itemPosition.x
itemY = itemPosition.y
# Now, use moveXY to move to itemX and itemY:
items = hero.findItems()
hero.moveXY(8, 34)
hero.moveXY(8, 9)
hero.moveXY(24, 10)
hero.moveXY(40, 9)
hero.moveXY(55, 10)
hero.moveXY(56, 34)
hero.moveXY(72, 34)
hero.moveXY(72, 57)
i am stuck so i got an success but when i pressed sumit i failed
Hi, @Riley_Capel, welcome to the CodeCombat discourse
Zax’s code wasn’t working code, were you using that?
If not, please post your code and we’ll see what we can do.
Danny
P.S. @ZAX155, You can revive a topic if you yourself need more help, I just don’t like it when people say stuff like “thanks” 4 years later
while True:
# This finds the nearest item.
item = hero.findNearestItem()
if item:
# This stores the item's pos, or position in a variable.
itemPosition = item.pos
# Put the X and Y coordinates of the item into variables.
itemX = itemPosition.x
itemY = itemPosition.y
# Now, use moveXY to move to itemX and itemY:
items = hero.findItems()
hero.moveXY(8, 34)
hero.moveXY(8, 9)
hero.moveXY(24, 10)
hero.moveXY(40, 9)
hero.moveXY(55, 10)
hero.moveXY(56, 34)
hero.moveXY(72, 34)
hero.moveXY(72, 57)