mIRC Home    About    Download    Register    News    Help

Print Thread
#175748 27/04/07 08:00 PM
S
Spitfire3292
Spitfire3292
S
on *:VARIABLE:{

I think this would be a nice addition to the events.

The way this would work is that each time a variable was set $1 would be the item (variable name) and $2- would be its value or something similar. I will show you an example of how this is helpful.

Suppose you have variable %A in 10 scripts. Each one of the scripts triggers at different times. Suppose you wanted a command to trigger when the variable was at a certain value. Instead of adding a check feature to all 10 scripts you could add something like this:

on *:VARIABLE:{ if ($1 = A) && ($2 = 100) { /echo -a * Variable $1 is now at value $2) } }

If the item was A and the value of it was 100, it would trigger.

Thanks for your time.

-Andrew

#175768 28/04/07 09:19 AM
O
Om3n
Om3n
O
As a scripted solution, you could use a signal to do this, with the use of a couple of aliases for var and set.

alias var { var $1- | signal varchange var $1- }
alias set { set $1- | signal varchange set $1- }

Or something along those lines, parsing the data would be a little more work because of the various var/set formats that can be used, but it is certainly doable.

#175769 28/04/07 09:28 AM
Joined: Sep 2005
Posts: 2,630
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Sep 2005
Posts: 2,630
Aliasing var will break local variables, because the variable will be local to the /var alias.

Aliasing set will also break /var considering mIRC calls /set -l internally and it will thus be local to the /set alias.

hixxy #175810 28/04/07 10:20 PM
O
Om3n
Om3n
O
Indeed, i guess i completely overlooked the behavior of local variables.

#175832 29/04/07 01:38 PM
Joined: Dec 2002
Posts: 580
N
Fjord artisan
Offline
Fjord artisan
N
Joined: Dec 2002
Posts: 580
There would be tremendous overhead to adding such a feature. It is also not very good programming. If you already have ten scripts modifying the same global variable, then why not create an eleventh that does this...
Code:
alias startChecks { .timerChecks 0 1 checkVariables }
alias checkVariables {
  if (%A > 100) { /echo -a * Variable $1 is now at value $2) }
  if (%Monkey > %Flying) { /echo -a * Cool Monkies can fly!! :) }
}


#175883 29/04/07 10:31 PM
Joined: Nov 2006
Posts: 1,552
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,552
Regarding performance, I get the same headache as NaquadaServ. Spiritfire3292 will not misuse such an event but, to be sure, many people out there will.
Think of While-Loops using global vars, or ppl not using a (fictive)
Code:
on *:var: {
 if (($1 == v.name) && ($2 > my.limit)) { stuff }
}

but
Code:
on *:var: {
 if (stuff isin $1) { triggering stuff }
}

or even
Code:
on *:var: {
 if (($hget(vars.to.watch,$1)) && ($2 // $ifmatch)) { stuff }
}

and what about things like
Code:
on *:var: {
 ...
 while ($2 > limit) { set $2 another lower value }
}

etc ? (just thinking aloud) Well, it might be a desirous event, anyway smile


Link Copied to Clipboard