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

Coincrumbs Help

I am stuck on coincrumbs because it keeps saying that the itemPosition is not defined.

while True:
    # This finds the nearest item.
    item = hero.findNearestItem()
    hero.findNearestItem()
    if "coin":
        # This stores the item's pos, or position in a variable.
        item.Position = 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:
        hero.moveXY(itemX,itemY)

You did not define

"coin"

Lydia

I am confused.(20 characters)

Notice how

"coin"

is red?
You have to define “coin”
like coin = hero.findNearestItem
or you can switch

if "coin":

with

if "item":

Lydia

Like this

while True:
    # This finds the nearest item.
    item = hero.findNearestItem()
    hero.findNearestItem()
    if "coin":
        # This stores the item's pos, or position in a variable.
        item.Position = item.pos
        # Put the X and Y coordinates of the item into variables.
        coin = hero.findNearestItem()
        coinX = coinPosition.x
        coinY = coinPosition.y
        # Now, use moveXY to move to itemX and itemY:
        hero.moveXY(coinX,coinY)

Nevermind I figured it out.

1 Like

Congrats! :partying_face: :partying_face:
Lydia

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