Module CorsixTH.CorsixTH.Lua.queue

Manages a list of `Humanoid`s which are waiting to use an `Object`.

A queue stores a list of humanoids waiting to use an object. For a reception desk, this is as expected. For a room, the queue is for the door, not the room. Hence the queue stores the list of patients waiting to enter (the traditional queue for the room), the list of staff waiting to enter (because of the door being in use for example), the list of staff and patients waiting to leave (again due to door being in use). Queues are currently implemented as normal Lua arrays, but you should access a queue via its methods rather than directly.

Functions

Queue:Queue () Constructor of a queue.
Queue:back () Get the last person in the queue (queue is not changed).
Queue:decreaseMaxSize (amount) Lower the max queue length.
Queue:expect (humanoid, callback) A humanoid is expected in a queue.
Queue:expectedSize () Get the number of expected patients.
Queue:front () Get the first person in the queue (queue is not changed).
Queue:hasEmergencyPatient () Check if the queue has an emergency patient.
Queue:increaseMaxSize (amount) Increase max queue length.
Queue:isFull () Retrieve whether the queue is full.
Queue:move (index, new_index) Move the person at position 'index' to position 'new_index'.
Queue:movePatient (index, new_index) Move an entering patient in the queue at position 'index' to position 'new_index'.
Queue:patientSize () Retrieve the total number of queued and expected patients.
Queue:pop () Pop first person from the queue.
Queue:remove (index) Remove person from the queue by index number.
Queue:removeValue (value) Remove a person by value from the queue.
Queue:reportedHumanoid (index) Get the 'index' real patient.
Queue:reportedSize () Get the number of real patients in the queue.
Queue:rerouteAllPatients (room_id) Called when reception desk is destroyed, or when a room is destroyed from a crashed machine.
Queue:setMaxQueue (queue_count) Set max queue length.
Queue:size () Total size of the queue, which are various people wanting in or out of the room.
Queue:unexpect (humanoid) A humanoid is canceled as expected in a queue.


Functions

Queue:Queue ()
Constructor of a queue.
Queue:back ()
Get the last person in the queue (queue is not changed).

Returns:

    Last person in the queue.
Queue:decreaseMaxSize (amount)
Lower the max queue length.

Parameters:

  • amount (int) Decrement length value of the queue.
Queue:expect (humanoid, callback)
A humanoid is expected in a queue.

Parameters:

  • humanoid - any humanoid expected for the room
  • callback - register a callback for when queue is 'destroyed'
Queue:expectedSize ()
Get the number of expected patients.

Returns:

    (int) Number of expected patients (in the near future).
Queue:front ()
Get the first person in the queue (queue is not changed). Note that first person may not be a patient, use Queue:reportedHumanoid to get patients

Returns:

    First person in the queue.
Queue:hasEmergencyPatient ()
Check if the queue has an emergency patient.

Returns:

    (boolean) Whether an emergency patient was found in the queue.
Queue:increaseMaxSize (amount)
Increase max queue length.

Parameters:

  • amount (int) Increment length value of the queue.
Queue:isFull ()
Retrieve whether the queue is full.

Returns:

    (boolean) Whether the queue is full.
Queue:move (index, new_index)
Move the person at position 'index' to position 'new_index'. Persons between 'index' and 'new_index' move one place to 'index'.

Parameters:

  • index (int) Index number of the person to move.
  • new_index (int) Destination of the person being moved.
Queue:movePatient (index, new_index)
Move an entering patient in the queue at position 'index' to position 'new_index'. Persons between 'index' and 'new_index' move one place to 'index'. Values are relative to the reported humanoids in the queue

Parameters:

  • index (int) Index number of the person to move.
  • new_index (int) Destination of the person being moved. or new_index (string) 'front' or 'back' as relative markers
Queue:patientSize ()
Retrieve the total number of queued and expected patients. return (int) Number of patients.
Queue:pop ()
Pop first person from the queue. Note that first person may not be a patient, use Queue:reportedHumanoid to get patients

Returns:

    First person in the queue.
Queue:remove (index)
Remove person from the queue by index number. Note that the person may not be a patient.

Parameters:

  • index (jnt) Index in the queue of the person to remove.

Returns:

    The removed person.
Queue:removeValue (value)
Remove a person by value from the queue.

Parameters:

  • value Person to remove.

Returns:

    Whether the person could be found (and was removed).
Queue:reportedHumanoid (index)
Get the 'index' real patient.

Parameters:

  • index (int) Index of the patient to retrieve (runs up to Queue:reportedSize).

Returns:

    Patient at the queried point in the queue.
Queue:reportedSize ()
Get the number of real patients in the queue.

Returns:

    (int) Number of real patients in the queue.
Queue:rerouteAllPatients (room_id)
Called when reception desk is destroyed, or when a room is destroyed from a crashed machine.

Parameters:

  • room_id Id of the room to reroute to, 'nil' for reception.
Queue:setMaxQueue (queue_count)
Set max queue length.

Parameters:

  • queue_count (int) New max queue length to set.
Queue:size ()
Total size of the queue, which are various people wanting in or out of the room. For a true patient queue count, use Queue:reportedSize.

Returns:

    (int) Number of various people in the queue.
Queue:unexpect (humanoid)
A humanoid is canceled as expected in a queue.

Parameters:

  • humanoid - Humanoid that is not coming to this queue.
generated by LDoc TESTING Last updated 2015-01-01 12:00:00