version 3 by Jesse McGrew
This extension provides a queue which can store up to 100 actions for various actors. Using the phrases explained below, we can add actions to the queue, remove them, and perform them. We can store and perform actions for any actor, even the player, although queuing them for non-player characters is probably more useful.
ADDING TO THE QUEUE
Using the action queue is similar to performing an action with "try":
queue opening the brown door;
queue the monkey trying eating the banana;
Normally, actions are added to the end of the queue, so if there are any other actions queued, the new one will be performed after them. If we want the new action to run first, we can use the word "immediately":
queue the monkey trying attacking the player immediately;
We can also write "trying the current action" to have someone mimic the player's action:
queue the mime trying the current action;
queue the mime trying the current action immediately;
PERFORMING FROM THE QUEUE
To animate our NPCs using the action queue, we'll need to run actions from the queue on a regular basis. If the game has more than one NPC, we can write this in an "every turn" rule:
perform the next queued action for every person;
Normally, if an NPC's action fails, nothing will happen. We can react to a failed attempt by writing an "unsuccessful attempt" rule for the action, and using a special option (which works with any of these "perform" phrases):
perform the next queued action for every person, following unsuccessful attempt rules;
If we only want to run one action at a time, we can name a specific actor, or just run the next queued action for whichever actor is scheduled to perform next:
perform the next queued action for Arnold;
perform the next queued action;
CHECKING THE QUEUE
We can use these conditions to check about certain actions:
if eating the cupcake is queued, ...
if the monkey trying eating the banana is queued, ...
if waiting is queued at least 5 times, ...
Or certain actors:
if any actions are queued for Arnold, ...
if the number of actions queued for Arnold is greater than 5, ...
Or we can use this syntax to check only the very next action for a particular person:
if eating the banana is queued next for the monkey, ...
DELETING FROM THE QUEUE
Actions are automatically removed from the queue as soon as they're performed, but we can also remove them without performing them:
delete the first queued action for Eliza;
delete the last queued action for Eliza;
delete all queued actions for Eliza;
Or empty the whole queue:
clear the action queue;