# Useful string constants.
PHRASE_IN = " in"
PHRASE_OUT = " out"
IDLE = "idle"
# The list of workers.
workers = hero.findByType("peasant", hero.findFriends())
# Use this array to control the worker queue.
queue = []
while True:
# Iterate all workers:
workers = hero.findByType("peasant")
queue = []
for worker in workers:
# If the worker's property "status" is "idle":
if worker.status == "idle":
# Say the free worker's name with the word " in":
hero.say(worker.id + " in")
# Add the worker in the end of the queue:
queue.append(worker)
item = hero.findNearestItem()
# If the item exists and the queue isn't empty:
if item and queue != 0:
# Say the name of the first in the queue worker
# with the word " out":
first = queue.shift()
hero.say(first.id + " out")
# Remove (pop) the first one from the queue:
this is my error
