Queue (Experimental) (Expression) — Skript
Addon: Skript · Category: Expression · Since: 2.10 (experimental)
Syntax
[a] [new] queue [(of|with) %-objects%]Description
Requires the <code>using queues</code> experimental feature flag to be enabled.
Creates a new queue. A queue is a set of elements that can have things removed from the start and added to the end.
Any value can be added to a queue. Adding a non-existent value (e.g. `{variable that isn't set}`) will have no effect. This means that removing an element from the queue will always return a value <i>unless the queue is empty</i>.
Requesting an element from a queue (e.g. `the 1st element of {queue}`) also removes it from the queue.
Examples
set {queue} to a new queue
add "hello" and "there" to {queue}
broadcast the first element of {queue} # hello
broadcast the first element of {queue} # there
# queue is now empty
set {queue} to a new queue of "hello" and "there"
broadcast the last element of {queue} # removes 'there'
add "world" to {queue}
broadcast the first 2 elements of {queue} # removes 'hello', 'world'