[SOLVED] Problems with "Passing Through"

My pet wolf isn’t moving at all, so my hero is just standing in place.

Here’s my code if you need it:

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 and pet.pos.y)
        # Else:
        else:
            if item == ("gem"):
                hero.moveXY(item.pos.x, item.pos.y)
3 Likes

Here is an image of the level and what’s happening (if you guys need it.)

3 Likes

Remove this line line from the else statement:

if item == ("gem"):

It is unnecessary and incorrectly written. I’m no Python expert but from what I’ve seen, this is how you should code it properly:

if item.type == "gem":
4 Likes

Thank you very much!

-Cameron

3 Likes

No problem. Please change the title of this question to [SOLVED] Problems with “Passing Through” so people do not accidentally answer again.

3 Likes

Thing is, I tried this and it didn’t work. What should I do?
Also, when I put and in between “pet.pos.x and y”, it says “You need to put ` in.” What do I do?

If you post your code it would be a lot easier to see what the issue is. Why are you putting ‘and’ in between pet.pos.x, pet.pos.y? ‘And’ shouldn’t be there. There should just be a comma separating the two.

If you have questions about how to format a method, just click on the method in question in the middle portion of the screen. It will give you the proper format. When you click on the moveXY(x, y) method you can see that there is no ‘and’ in the parenthesis.

Thanks
I didn’t know. I looked at the picture and saw the word "AND"
I wasnt sure what to do.

Didn’t work…but figured it out for anyone else who has trouble!(python)

Mod edit:

(Solution removed)

Please do not post solutions. Thanks.