Stranded in the Dunes: item.type == "potion" not recognized?

It seems at the end of the, Skeleton King, the potions aren’t being recognized. When I click on say a skeleton, a little halo circle pops up and it clearly tells me this is a skeleton, but when I try to click on a potion, nothing happens. No information is shown.

The only reason I bring this up is I just wanted to have my character retrieve it through my loop, instead of having to make my toon move to it via a flag. It seems like it doesnt recognize the item.type == “potion”.

Does that seem right to you? I am more than willing to share my code…its totally possible I effed that particular part of the code, but I may have gotten it right as well.

Btw I cleared the level, so it’s not a big deal if I do not receive a prompt response.

Cheers,
-J

2 Likes

Can we see just the code for retrieving the potion?

I just tried it on that level and those potions do have a type of “potion” and they are working as expected.

My guess is that you may have used hero.move(item.pos) and are only taking one step towards the potion but we need to see the code to sort it out.

1 Like

Ok so here is my function:

def getPotion():
item = hero.findNearestItem()
if item.type == “potion”:
hero.moveXY(item.pos.x, item.pos.y)
pass

Then I am running it at the end of my nested if statement:

if flag:
    -------------
elif ------:
    if ------:
        -------
        -------
        pass
    elif ---------:
        if ----------:
            ---------
            pass
        elif -----:
            -------
            pass
        
    else:
        getPotion(item)
        pass

I am trying to keep this answer free, but if this is insufficient I can just email someone what I coded.

1 Like

I’m not sure if this is your problem or not, but your function doesn’t accept a parameter, so the function call should just be getPotion()

1 Like

Ok so I tweaked that bit. I am still not able to get the potions without manually dropping a flag… My toon just sits there. So I took a couple of screen grabs, the first one shows me trying to click…as you can see it doesn’t recognize the potion type.

So yeah Im not sure what is happening. Like I said if need be, send me an place I can email my code. Maybe my stuff is off.

cheers.

1 Like

That Contact button at the bottom of the screen will put you in touch with support. Or you can email team@codecombat.com for help.

1 Like

Contacted support.

Thanks!

1 Like

When you call the function you call getPotion(item), but your function definition does not call for an item on input.
So you should just call “getPotion()” as you have the function locate and create its own variable locally.

2 Likes