new CommandQueue()
Members
-
lagRemaining :number
-
Seconds until the next command can be executed
-
msTilNextRun :number
-
Milliseconds til the next command can be executed
-
queue :Array.<Object>
-
Methods
-
addLag(amount)
-
Safely add lag to the current queue. This method will not let you add a negative amount as a safety measure. If you want to subtract lag you can directly manipulate the
lag
property.Parameters:
Name Type Description amount
number milliseconds of lag
-
enqueue(executable, lag)
-
Parameters:
Name Type Description executable
CommandExecutable Thing to run with an execute and a queue label
lag
number Amount of lag to apply to the queue after the command is run
-
execute() → {boolean}
-
Execute the currently pending command if it's ready
Returns:
boolean -whether the command was executed
-
flush()
-
Flush all pending commands. Does not reset lastRun/lag. Meaning that if the queue is flushed after a command was just run its lag will still have to expire before another command can be run. To fully reset the queue use the reset() method.
-
getMsTilRun(commandIndex) → {number}
-
Milliseconds until the command at the given index can be run
Parameters:
Name Type Description commandIndex
number Returns:
number -
getTimeTilRun(commandIndex, milliseconds) → {number}
-
For a given command index find how many seconds until it will run
Parameters:
Name Type Description commandIndex
number milliseconds
boolean Returns:
number -
reset()
-
Completely reset the queue and any lag. This is fairly dangerous as if the player could reliably reset the queue they could negate any command lag. To clear commands without altering lag use flush()