Queue Manager help

# 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

you need to delete the queue array that is inside the while loop, change first = queue.shift() with first = queue.pop(0), and make it if item and len(queue) > 0: instead of if item and queue != 0:

Thanks so much it worked

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