mIRC Home    About    Download    Register    News    Help

Print Thread
#244591 12/03/14 11:40 AM
Joined: Mar 2014
Posts: 16
D
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 16
I am hacking about some code for an event handler and rather than handling the event straight away, as it does now, I'd like to execute large parts of it after a delay.

So I am using something like:

timername 1 60 aliasnametobeexecuted

However, because the code was created to run normally, without delays, it makes extensive use of $nick and $chan and so on ... so will not work with the timer delay, since it blanks out $nick $chan etc.

Is there any way of setting the values of $nick and $chan so they are preserved across timer events?

So in other words I'd like to be able to do:

Code:
alias timerstart{
  timerX 1 60 hello
}

alias hello(
  msg $chan Hi there $nick!
  ; ... and lots of other code that uses $chan and $nick
}


and not

Code:
alias timerstart{
  timerX 1 60 hello $chan $nick
}

alias hello(
  msg $1 Hi there $2!
}


if at all possible

Last edited by davethejackal; 12/03/14 11:58 AM.
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
You may be able to structure your code to sleep instead of using a timer: /sleep 60000 will pause the script at that line for 60 seconds

Code:
alias sleep {
  if ($1 !isnum 1-) return
  var %a = $ticks $+ .vbs
  write %a wscript.sleep $1
  .comopen %a wscript.shell
  if (!$comerr) .comclose %a $com(%a,Run,3,bstr,%a,uint,0,bool,true) 
  .remove %a
}

Joined: Mar 2014
Posts: 16
D
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 16
Thanks very much .. but will sleep allow other parts of the code to execute if other events occur?

Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
Yes, other events still take place.


Link Copied to Clipboard