[SOLVED] Method Issue - Stack Triage (Python)

Level Link
The method below is giving me an error:

hero.command(peasant, "pickUpItem", item)

Screenshot 2021-12-19 14.39.31

And in both, the hints (copied it from there) and the comments, it is written in the format of a command.
This is the code snippet that I’m facing trouble with:

peasant = hero.findFriends()[0]
items = peasant.findItems()
for item in items:
    # Command the peasant "pickUpItem" an item:
    hero.command(peasant, "pickUpItem", item)
    pass

Help would be appreciated :slight_smile:

1 Like

should this be in bug categories?

I forgot to categorize it, i wanted to put it in level Help, but maybe as you said Bugs is better.

What is all of your code and what is your equipment for this level?

1 Like

Code:

# Sort out and deliver items:
# Yak - potion, Yeti - mushroom, Skeleton - lightstone.
yetiPos = {"x": 60, "y": 36}
yakPos = {"x": 40, "y": 52}
skeletonPos = {"x": 58, "y": 56}

peasant = hero.findFriends()[0]
items = peasant.findItems()
for item in items:
    # Command the peasant "pickUpItem" an item:
    if item:
        hero.command(peasant, "pickUpItem", item)
    

while True:
    # Check an item on the top of the stack.
    topItem = peasant.peekItem()
    if not topItem:
        break
    # If topItem type is "potion":
    if topItem.type == "potion":
        # Command to "dropItem" it to yaks:
        hero.command(peasant, "dropItem", yakPos)
    # If topItem type is "mushroom":
    elif topItem.type == "mushroom":
        # Command to "dropItem" it to yetis:
        hero.command(peasant, "dropItem", yetiPos)
       
    # If topItem type is "lightstone":
    elif topItem.type == "lightstone":
        # Command to "dropItem" it to skeletons:
        hero.command(peasant, "dropItem", skeletonPos)
    

Equipment:
Screenshot 2021-12-20 09.09.51

@abc

I can’t seem to recreate the issue that you have. Your code is the same as mine. As for equipment and hero, I used Griffin Wool Hat and Nalfar, the only differences from your equipment and hero. However, I get no error.

1 Like

I will try switching to warrior, and then i will see what happens

Okay … I switched to Anya and the code worked perfectly … Anyways, thank you @abc for your help

1 Like

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