Level Link
The method below is giving me an error:
hero.command(peasant, "pickUpItem", item)
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
# 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)
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.