mIRC Homepage
Posted By: Insanatic on *:REACH: or on *:SET: - 14/12/03 09:28 AM
I posted something about this before and i guess i didnt think it through enough, but now it hink i may hav:

Once a %variable reaches a certain number it would perform specified commands.
Example:
on *:SET:%counter.msgs:1000:/set %counter.msgs 0
This would meen once the variable %counter.msgs reaches 1000 it would reset it self.

Hope that does make sense,
Thanks always,
Baden
Posted By: Narusegawa_Naru Re: on *:REACH: or on *:SET: - 14/12/03 10:23 AM
actually i like this idea. but not for a reset. perhaps a switch denoting the maximum value increation such as

/var -m5 %blah = 4

/inc %blah

now its 4 because it reached 5 wich was the max and reset to 4.
Posted By: madewokherd Re: on *:REACH: or on *:SET: - 14/12/03 02:26 PM
Wouldn't it be easier to make an alias to inc the variable and check whether or not it is at that point? It seems to me that having an event like this would greatly slow down the processing of scripts.
Posted By: Seifer Re: on *:REACH: or on *:SET: - 14/12/03 08:59 PM
I think it's the opposite way around, an alias would be much slower than if it were an internal function.
Posted By: madewokherd Re: on *:REACH: or on *:SET: - 14/12/03 09:31 PM
In the one case you're talking about, yes, it would be faster.

But every other time you set a variable, it would be slower.
Posted By: Strider Re: on *:REACH: or on *:SET: - 14/12/03 09:56 PM
I agree with you. There's no need for an event or an option here, since you are the one who increments the value of the variable with an alias or with an event.

The best way of doing this is by adding the condition to the event or alias where the variable is changed.
Posted By: KingTomato Re: on *:REACH: or on *:SET: - 15/12/03 12:55 AM
BTW, with your comment about "only one to increment it", check out /inc and /dec's -c switch.
Posted By: BoredNL Re: on *:REACH: or on *:SET: - 15/12/03 08:16 AM
you can just create some basic script to do this whenever you need this. The script would be slower than if it was implimented internally, but I have to agree with madewokherd that it would definately hinder over all performance and all for a very specific circumstance.

Here's an example script for you:

Code:
alias wee { 
  echo -a And here we go..  (10 is the limit as set in the alias sdi, and 1 is the default number)
  set2 wee 1
  echo -a Set it as: %wee
  inc2 wee 6
  echo -a Added 6: %wee
  dec2 wee 3
  echo -a Subtracted 3: %wee
  inc2 wee 50
  echo -a Incremented it 40 past it's limit: %wee
  unset %wee
  echo All done!
}
alias set2 {
  set % $+ [ $1- ]
  sdi $1
  }
alias inc2 { 
 inc % $+ [ $1- ]
  sdi $1
}
alias dec2 { 
 dec % $+ [ $1- ]
  sdi $1
}
alias -l sdi { if ( [ % $+ [ $1 ] ] >= 10) {  set  % $+ [ $1 ] 1 } }


If you have the number decreasing every second or incrementing every second or something, then I suggest to you to create a more complex script that will have a timer running evert second, which will run an alias which will look through a list of variable names which would be stored in a hash file to check all the variables every second, removing variables that stop decreasing or incrementing, untill the hash file is empty, then the timer would be unset.

I think Narusegawa_Naru's suggestion is a much better suggestion, but still not a very important one.
Posted By: Insanatic Re: on *:REACH: or on *:SET: - 15/12/03 09:43 AM
But how would that make it quicker? it has to go through like 15 lines to do only a few things.

BTW, i only used the reset as an example. I think it would
a) be easier for scripters
b) quicker
Oh well its only my opinion,
Thanks as always
Baden
Posted By: Strider Re: on *:REACH: or on *:SET: - 15/12/03 10:07 AM
So?

If you want to perform a command after certain time has passed, it's best that you use a timer, and not an incremental variable.
Posted By: KingTomato Re: on *:REACH: or on *:SET: - 15/12/03 06:17 PM
I'm not here to get in an argument, but its not correct to assume "the user is the only one making the increment". Making timers is again slow, and tedious. All I was suggesting is that there are alternative increments. I mean just because in script 1 you use /inc -c doesn't mean in script 2 you can't sue a /dec.
Posted By: Strider Re: on *:REACH: or on *:SET: - 16/12/03 06:14 AM
Read my original post and notice how I did not use the word "only".
Posted By: KingTomato Re: on *:REACH: or on *:SET: - 16/12/03 06:32 PM
'the one', means only in my book. Its like saying they are 'the one' with the password, only they have the password.
© mIRC Discussion Forums