[Solved] Passing through help!


#1

My wolf won’t move at all. Here’s my code:
while True:
item = hero.findNearestItem()
if item:
# If item.type IS NOT EQUAL TO "gem"
if item.type != “gem”:
# Then follow your pet wolf.
hero.moveXY(pet.pos.x, pet.pos.y)
# Else:
else:
if item == “gem”:
# Move to the gem’s position.
hero.moveXY(item.pos.x, item.pos.y)


#2

My wolf just moved but my hero won’t pick up any gems


#3

It’s very hard to read your code because you didn’t format it using the </> button. From now on please do that and it will appear here exactly as it does in the game.

while True:
    item = hero.findNearestItem()
    if item:
    # If item.type IS NOT EQUAL TO "gem"
        if item.type != “gem”:
        # Then follow your pet wolf.
        hero.moveXY(pet.pos.x, pet.pos.y)
    # Else:
    else:
        if item == “gem”:
        # Move to the gem’s position.
        hero.moveXY(item.pos.x, item.pos.y)

Look at how you locate item in the “if” statement. Then look at how you locate item in the “else” statement. The first is correct. The second is not.


#4

I’m still having a little trouble even with the correct coding


#5

nevermind got it!!! thanks