Safe Idle Command Queuing

On 3k client side scripts are allowed, but one thing they are NOT allowed to do is keep you from going idle when you are away from the keyboard.
However, there are often times when you want to perform a command periodically, or trigger it from a specific message coming from the mud.
Triggering the command directly could break the 3k rules if you're not sitting in front of the PC when it happens, so here is a method of safely saving up
these commands for when you return.

Firstly, an alias to add commands to the queue

#ALIAS aQueueCommand {
  #T+ CommandQueue
  #ADDITEM vCommandQueue {%-1}

Next, a trigger that will detect whenever you type anything in the command line and send it to the mud. When you do this, it will then send all of the commands that have been queued up through to the mud, and clear them from the queue.

#CLASS {CommandQueue}
#VAR vCommandQueue {}
#ONINPUT {.*} {
  #IF (%numitems( @vCommandQueue) > 0) {
    #ECHO ==== Queued Commands ====
    #FORALL {@vCommandQueue} {
      #SEND {!%i}
      #delitem vCommandQueue {%i}
  #T- CommandQueue
  } "" {regex}

Finally, an example of how this could be used.

#TRIGGER {^Necromancer status saved.$} {
  aQueueCommand reinforce equip
  aQueueCommand unholy ground

This trigger fires whenever the Necromancer guild object repowers. At this point, the commands "reinforce equip" and "unholy ground" are queued up. Next time I type anything into the mud after a repower, my equipment will be automatically reinforced, and I will then cast unholy ground on myself.

N.B. it has been noticed that cMud sometimes loses the "regex" status on the ONINPUT trigger. Check to make sure after you have installed the code that the ONINPUT trigger has the Regular Expression (Regex) tickbox checked.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License