*chuckle Peeka*
Great stuff Nick, but not really applicable to the problem that started this thread. Sure it could be modified to work but that would require a good knowledge of Lua. The problem is that he wants to queue a couple of commands and then either work his way through the whole queue or pause the queue and later resume it but not efter a fixed time but rather starting it again with a command.
What would really be needed is a command/alias to queue something, a command/alias to start processing the queue and one to pause it.
The way I would do it is...
I would put this in my Perl script file...
# Command queue variables
@cmdQueue = ();
$pauseQueue = 0;
# Command queue code
sub processQueue() {
my $cmd;
# If we should not pause the queue and if the queue contains some commands...
if ( ! $pauseQueue && scalar @cmdQueue ) {
# Shift a command from the queue...
# Since what we want is a FIFO queue we shift commands OFF the queue and push them ON.
$cmd = shift @cmdQueue;
# Use this if you want to be able to queue MUSHClient aliases and/or speedwalks etc...
$world->Execute( $cmd );
# ...or use this if you just want to send stuff to the MU*, this is quicker
# coz it bypasses any command queues and speedwalk queues.
# $world->SendImmediate( $cmd );
}
}
sub queueCmds( $$$ ) {
# We are just interested in the arguments so discard the other stuff.
shift; shift;
# Get the array reference from the call stack.
my $arefArgs = shift;
# Get the count from the args...
my $count = shift @{$arefArgs};
# ...and get the command string.
my $cmdStr = shift @{$arefArgs};
# Turn this on if you like confirmation msgs.
#$world->note( "#Queueing ${count} x \'${cmdStr}\'." );
while ( $count ) {
push @cmdQueue, $cmdStr;
$count--;
}
}
...and then have this timer...
<timers>
<timer script="processQueue" enabled="y" second="0.50" >
</timer>
</timers>
...and this alias...
<aliases>
<alias
script="queueCmds"
match="queue ([\d]+)\s(.+)"
enabled="y"
regexp="y"
sequence="100"
>
</alias>
</aliases>
...Oppps! Forgot a speedwalk alias...
<aliases>
<alias
match="speedwalk (.+)"
enabled="y"
regexp="y"
send_to="12"
sequence="100"
>
<send>{
my $arg = "%1";
$arg =~ s/ //g;
my @cmds = split //, $arg;
my $count = undef;
foreach my $cmd ( @cmds ) {
if ( $cmd =~ /[0-9]/ ) {
if ( $count == undef ) {
$count = $cmd;
} else {
$count .= $cmd;
}
} else {
$count = 1 if ( $count == undef);
queueCmds( 0, 0, [ $count, $cmd ] );
$count = undef;
}
}
}</send>
</alias>
</aliases>
The trigger ALLWAYS runs, but does not trigger when you are not connected so if you disconnect and then reconnect again without restarting the client, the client will just take up where it left off processing the queue on a FIFO basis.
Now you can either do:
queue 10 smile
...or...
speedwalk 2s3e15nued
...or...
speedwalk 2s 3e 15n u e d
Hmmm...I wish I would think things through and test them before posting...almost forgot (this is my 10th or so edit of this post :) to mention how to PAUSE the speedwalk/command queue.
The speedwalk reuses the command queue and that means that the only thing needed to pause the speedwalk is to set the global variable pauseQueue to a non-zero value. To resume the processing of the queue, just set the variable back to zero.
// Fredrik