weeper
05-07-2007, 10:01
After reading this tutorial you will be able to make conditional events with the following characteristics:
Make something happen only if 2 conditions are true.
Make something happen only once when a condition is true and only can happen again after the condition becomes false and true again.
Combination of both
Events that require 2 conditions to be true.
The following example will make a ding ONLY if the last msg is "hi" and was sent by "John"
1
#number=#
1
0
300
0
exiva _var = 0
$lastsender$
#string=#
John
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$lastmsg$
#string=#
hi
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva testding
Basically we set 4 conditional events here.
1. This event is always true (1=1). This one sets the custom variable $_var$ to "0".
2. This is actually the first condition that triggers our action. If the variable $lastsender$ returns "John" it will add +1 to our custom variable $_var$.
3. This is our second condition for the action to get done. If the variable $lastmsg$ returns "hi" it will add +1 to our custom variable $_var$.
4. This final event checks the current value of our custom variable called $_var$. If the value is "2" (both conditions were true, so each one added +1 to the variable) then it executes the action we want to get done. Which in this case is to make a ding using exiva testding.
Note: In this one as long as the 2 conditions keep being true it will spam dings. Later on this post I will explain how to avoid this.
Events that only are true once and can only be true again after they became false
The following example will ding ONLY ONCE whenever you get a message saying "hi". It can only ding again if you get a message different than "hi" and then "hi" again.
$lastmsg$
#string<>#
hi
0
300
0
exiva _variable = 0
$lastmsg$
#string=#
hi
0
500
0
exiva _variable = $numericalexp:{$_variable$}+1$
$_variable$
#number=#
1
0
300
0
exiva testding
$_variable$
#number>=#
500
0
300
0
exiva _variable = 2
We set four conditional events here too, but actually the last one is not totally necessary.
1. If the variable $lastmsg$ is something DIFFERENT than "hi" then it will set our custom variable "$_variable$" to "0".
2. If the variable $lastmsg$ is the same as "hi". It will add +1 to a custom variable called $_variable$.
3. If our custom variable is equal to 1. Then it will ding.
4. This is not actually necessary but if the variable $lastmsg$ keeps being "hi". The count can go very high so to avoid this, we set this event that checks if the custom variable called $_variable$ has reached 500. If so, it will make it go back to 2. I chose 2 because it must be a number that's after the one that we set to make the action (in this case 1) so the condition number 3 keeps being false.
Combination of both types of events.
Now that you know how to make this 2 types of events. You may have already figured out by yourself how to combine them.
The following example combined the 2 types we have seen.
$lastsender$
#string<>#
John
0
300
0
exiva _var = 0
$lastmsg$
#string<>#
hi
0
300
0
exiva _var = 0
$lastsender$
#string=#
John
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$lastmsg$
#string=#
hi
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva testding
$_var$
#number>=#
500
0
300
0
exiva _var = 3
1. If the variable $lastsender$ returns something different than "John" then it will set custom variable $_var$ to 0.
2. If the variable $lastmsg$ returns something different than "hi" then it will set custom variable $_var$ to 0.
3. If variable $lastsender$ returns "John" it will add +1 to custom variable $_var$.
4. If variable $lastmsg$ returns "hi" it will add +1 to custom variable $_var$.
5. If custom variable $_var$ is equal to 2, then it will ding using "exiva testding"
6. If custom variable went too high (500) because both conditions kept being true for a long time, then it will reset it back to 3. (Must be a number above 2 so that condition number 5 keeps being false.)
I hope that with this little tutorial you are able to make more complex conditional events that suit your needs.
EDIT: 30 views and no comment? I would like to state that feedback is greatly appreciated.
Make something happen only if 2 conditions are true.
Make something happen only once when a condition is true and only can happen again after the condition becomes false and true again.
Combination of both
Events that require 2 conditions to be true.
The following example will make a ding ONLY if the last msg is "hi" and was sent by "John"
1
#number=#
1
0
300
0
exiva _var = 0
$lastsender$
#string=#
John
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$lastmsg$
#string=#
hi
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva testding
Basically we set 4 conditional events here.
1. This event is always true (1=1). This one sets the custom variable $_var$ to "0".
2. This is actually the first condition that triggers our action. If the variable $lastsender$ returns "John" it will add +1 to our custom variable $_var$.
3. This is our second condition for the action to get done. If the variable $lastmsg$ returns "hi" it will add +1 to our custom variable $_var$.
4. This final event checks the current value of our custom variable called $_var$. If the value is "2" (both conditions were true, so each one added +1 to the variable) then it executes the action we want to get done. Which in this case is to make a ding using exiva testding.
Note: In this one as long as the 2 conditions keep being true it will spam dings. Later on this post I will explain how to avoid this.
Events that only are true once and can only be true again after they became false
The following example will ding ONLY ONCE whenever you get a message saying "hi". It can only ding again if you get a message different than "hi" and then "hi" again.
$lastmsg$
#string<>#
hi
0
300
0
exiva _variable = 0
$lastmsg$
#string=#
hi
0
500
0
exiva _variable = $numericalexp:{$_variable$}+1$
$_variable$
#number=#
1
0
300
0
exiva testding
$_variable$
#number>=#
500
0
300
0
exiva _variable = 2
We set four conditional events here too, but actually the last one is not totally necessary.
1. If the variable $lastmsg$ is something DIFFERENT than "hi" then it will set our custom variable "$_variable$" to "0".
2. If the variable $lastmsg$ is the same as "hi". It will add +1 to a custom variable called $_variable$.
3. If our custom variable is equal to 1. Then it will ding.
4. This is not actually necessary but if the variable $lastmsg$ keeps being "hi". The count can go very high so to avoid this, we set this event that checks if the custom variable called $_variable$ has reached 500. If so, it will make it go back to 2. I chose 2 because it must be a number that's after the one that we set to make the action (in this case 1) so the condition number 3 keeps being false.
Combination of both types of events.
Now that you know how to make this 2 types of events. You may have already figured out by yourself how to combine them.
The following example combined the 2 types we have seen.
$lastsender$
#string<>#
John
0
300
0
exiva _var = 0
$lastmsg$
#string<>#
hi
0
300
0
exiva _var = 0
$lastsender$
#string=#
John
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$lastmsg$
#string=#
hi
0
300
0
exiva _var = $numericalexp:{$_var$}+1$
$_var$
#number=#
2
0
300
0
exiva testding
$_var$
#number>=#
500
0
300
0
exiva _var = 3
1. If the variable $lastsender$ returns something different than "John" then it will set custom variable $_var$ to 0.
2. If the variable $lastmsg$ returns something different than "hi" then it will set custom variable $_var$ to 0.
3. If variable $lastsender$ returns "John" it will add +1 to custom variable $_var$.
4. If variable $lastmsg$ returns "hi" it will add +1 to custom variable $_var$.
5. If custom variable $_var$ is equal to 2, then it will ding using "exiva testding"
6. If custom variable went too high (500) because both conditions kept being true for a long time, then it will reset it back to 3. (Must be a number above 2 so that condition number 5 keeps being false.)
I hope that with this little tutorial you are able to make more complex conditional events that suit your needs.
EDIT: 30 views and no comment? I would like to state that feedback is greatly appreciated.