ST Queue
A synced queue of players, such as performers waiting for the stage or a game's waiting line. Add it with Add Component → StageTime
→ ST Queue. Each entry holds the player who asked, a number (key, for example an item's row in an
ST Data Table) and an optional short text. StageTime syncs the entries itself, so they do not
count against your script's synced variables, and players who join later see
the whole queue.
The queue only holds entries. What the first entry means (play a video, move the player to a stage, start their turn) is up to your scripts, which also remove it when the turn is over.
| Field | |
|---|---|
capacity | How many entries the queue holds (1 to 16, default 10) |
onePerPlayer | Each player can have one entry at a time |
requestCooldown | Seconds a player waits between requests (default 5) |
| Member | |
|---|---|
Request(key, text) | Adds an entry for the local player. Ignored when the queue is full, the player already has an entry or is in the cooldown. Text is cut to 60 characters |
Remove(index) | Removes an entry (0 = first). Players can remove their own; hosts and moderators any |
Clear() | Removes every entry. Hosts and moderators only |
count | The number of entries |
currentPlayer | The first entry's player (whose turn it is), or null when the queue is empty |
GetPlayer(index), GetPlayerId(index), GetKey(index), GetText(index) | One entry |
GetEntryId(index) | A number that identifies the entry while it is queued (0 outside the queue). A new entry always gets a new id, even for the same player and item, so compare ids to see whether the first entry changed |
IndexOf(player) | The player's first entry, or -1 |
cooldownRemaining | Seconds until the local player may request again |
StageTime checks every request and removal on one device for the whole room, so the rules hold even if two players press at the same moment. A player's entries are removed when they leave.
Scripts on the same GameObject get OnQueueChanged() on every device whenever an entry is added or removed, and
once after joining.
public class Requests : StageTimeBehaviour
{
public TMP_Text list;
private STQueue queue;
void Start() => queue = GetComponent<STQueue>();
public void RequestItem() => queue.Request(42, "Item 42");
public override void OnQueueChanged()
{
string text = "";
for (int i = 0; i < queue.count; i++)
text += (i + 1) + ". " + queue.GetText(i) + " (" + queue.GetPlayer(i).displayName + ")\n";
list.text = text;
}
}
Playing a queue on a video player
A script decides what happens when the first entry changes. For a queue of videos, the queue video player example goes on the ST Video Player's GameObject (so it gets the video events) and watches the queue's first entry:
- The device of the player whose turn it is calls
PlayURL, which makes them the video'srequester, so Sync To Requester follows them. - When the video ends or fails, that player's device removes their entry; the next player's device then starts theirs.
- When the queue empties, the requester's device (or the master, if the requester left) stops the video.
Each player starts their own video, so set the video player's controlAccess to Everyone and decide in your
scripts who may use the other video controls. The catalogue browser and
request queue examples complete the station.
The queue runs in Build & Test, not in the Play preview.