Play Home Contribute GitHub Join Us Discourse Staff Members GitHub Contribution Guides Team

Cursed Valley! My character is not picking up the potion!


Hey CodeCombat supporters! I’m struggling with the cursed valley, and in general Sarven Desert :frowning:

The other levels leading up to this were manageable, but I feel like it’s a lot harder now. I think I’m really struggling with the idea or concept of arrays. If anyone has a cool analogy, I’d love to hear it.

Your help and insight would be appreciated, my guy doesn’t pick up the potion :frowning:

while True:
    item = hero.findNearestItem()
    # Take only the items with a "potion" type AND only when your health is less than a quarter of the maxHealth.
    if item and < and item.type == "potion":
        hero.moveXY(item.pos.x, item.pos.y)

#2 < < hero.maxHealth / 4


thanks :smile:

so many clumsy mistakes… when will it end haha


I was having the same problem with this level as well. I ended up changing it to Emm_S’s code and it worked but I’m still wondering about my code.
item = hero.findNearestItem()
if item and item.type == “potion” and < hero.maxHealth / 4:
hero.moveXY(item.pos.x, item.pos.y)

Does it matter what order they go in?