mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Mar 2014
Posts: 16
D
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 16
Add a switch to timers so that when started from within an event, the command triggered by the timer executes as if it had been triggered inside the event (so has access to $nick etc).

If this is already available please do tell eek

Last edited by davethejackal; 12/03/14 12:09 PM.
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Such a switch is not required, /timer always has access to $nick or any other local identifier currently.
Code:
on *:text:!test:#test:.timer 1 1 echo -a $nick just said !test
This will always work.


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Jan 2004
Posts: 1,358
L
Hoopy frood
Offline
Hoopy frood
L
Joined: Jan 2004
Posts: 1,358
As per his other topic, he is calling an alias which makes use of $nick, and he doesn't want to pass $nick to the alias.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
Right, well then, that's not possible.

@davethejackal: Keep in mind more than one event could trigger before the alias is called:
Code:
;let's suppose -X is the new switch you are talking about
on *:text:!test:#test:.timer -X 1 1 dosomething
alias dosomething echo -a $nick
What if A and B type !test at the same time? Both events will trigger and create a timer before one of those timer actually triggers, so how would mIRC know which value $nick should return?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2014
Posts: 16
D
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 16
In the instance triggered by A $nick would be A.
In the instance triggered by B $nick would be B.

The timer event acts as if it was triggered by the person who triggered the event, like wot I done said.

Hence, if the B version triggers before the A, the B version of the timer would be 'destroyed' and replaced with the A version, and vice version.

It's up to the developer to stop this happening if that's not what they want.

Pretty much exactly what would happen if you passed the $nick as a parameter.

Last edited by davethejackal; 15/03/14 01:09 AM.
Joined: Apr 2004
Posts: 871
Sat Offline
Hoopy frood
Offline
Hoopy frood
Joined: Apr 2004
Posts: 871
Originally Posted By: davethejackal
Pretty much exactly what would happen if you passed the $nick as a parameter.

It would probably help if you explained why this is not sufficient for you. It is pretty simple to rewrite an alias to use $1 instead of $nick, for example.


Saturn, QuakeNet staff
Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
But passing $nick as a parameter is the way to go, what you are looking for is just aesthetic.
You can't really ask such a feature here, you would be asking for a switch everytime it can simplify your code a bit for a specific situation.
Here it's about $nick but what if someone request the exact same thing for all the others local identifiers: $fulladdress $chan etc, would we add a new switch for these? We would pass those value as parameters...


#mircscripting @ irc.swiftirc.net == the best mIRC help channel
Joined: Mar 2014
Posts: 16
D
Pikka bird
OP Offline
Pikka bird
D
Joined: Mar 2014
Posts: 16
Yes, that was the general idea. The entire 'environment' of a call would be transferred, not just $nick.

If would mean code was instantly scalable from single instance execute-now to multiple threaded, timer-schedulable.

Joined: Jul 2006
Posts: 4,145
W
Hoopy frood
Offline
Hoopy frood
W
Joined: Jul 2006
Posts: 4,145
There are no threads in mIRC, just delayed operations on the same thread.
You are really only asking about getting that /timer's switch to keep the exact same code of an alias, that has been made not be called by a timer, just because you are now using a timer.
There are many problems with this suggestion anyway, how do you access the copied environement? Using $nick, no problem, but if you use $1- for example, which is as local as $nick, will $1- be the current parameters passed to the alias or the old $1- definition?
Why do you refuse to pass the information as a parameter to the alias?


#mircscripting @ irc.swiftirc.net == the best mIRC help channel

Link Copied to Clipboard