Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ General
➜ if * then * trigger help
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Karl_Newbie
USA (23 posts) Bio
|
Date
| Tue 24 Aug 2004 10:50 PM (UTC) Amended on Tue 24 Aug 2004 10:53 PM (UTC) by Karl_Newbie
|
Message
| I know how to do simple 'if then' statements for triggers
-----------------
if world.GetVariable("pa") = "0" then
send "command1"
else
end if
--------------
(I have another trigger which changes that variable to 1 at times)
But how can I take it up a notch to include more cause variables with possible alternative conclusions. Ideally it would be sort of like this.
if world.GetVariable("A") = "0" & world.Getvariable ("B") = "0" & world.Getvariable ("C") = "0" then
send "command1"
else
if world.GetVariable("A") = "1" & world.Getvariable ("B") = "0" & world.Getvariable ("C") = "0" then
send "command2"
else
if world.GetVariable("A") = "0" & world.Getvariable ("B") = "0" & world.Getvariable ("C") = "1" then
send "command3"
end if
Is something like that possible?
Basically I have triggers for hunger/thirst/spells status which switch their respective variable to 1 or 0. I want MC to evaluate those variables and send the appropriate command upon matching a generic balance regained trigger and or timer. IE "eat from bowl" if the "I'm hungry" status variable is 1, "drink sip from glass" if the thirsty variable is 1, or go ahead with a "perform action" if all the previous variables are 0.
| Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #1 on Tue 24 Aug 2004 11:06 PM (UTC) Amended on Tue 24 Aug 2004 11:07 PM (UTC) by Flannel
|
Message
| Yes, that is possible.
Except you'd use ElseIf.
And you can also break it down and nest them, such as...
if world.GetVariable("A") = "0" Then
if world.Getvariable ("B") = "0" then
if World.getvariable("C") = "0" Then
send "command1"
Elseif World.getvariable("C") = "1"
send "command3"
end if
end if
elseif world.GetVariable("A") = "1" & world.Getvariable ("B") = "0" & world.Getvariable ("C") = "0" then
send "command2"
end if
Or if you just used 0 and 1, then you could disreguard that elseif (for checking c, since if C isnt 0, its 1)
like this:
if world.GetVariable("A") = "0" Then
if world.Getvariable ("B") = "0" then
if World.getvariable("C") = "0" Then
send "command1"
Else
send "command3"
end if
end if
|
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Jlzink
USA (15 posts) Bio
|
Date
| Reply #2 on Thu 26 Aug 2004 01:39 AM (UTC) Amended on Thu 26 Aug 2004 01:43 AM (UTC) by Jlzink
|
Message
| that is one way, but here is yet another way
dim var1, var2, var3
var1 = world.getvariable("A")
var2 = world.getvariable("B")
var3 = world.getvariable("C")
if var1 = 0 And var2 = 0 And var3 = 0 Then
send "command1"
Elseif var3 = 1
send "command3"
end if
if var1 = 1 And var2 = 0 And var3 = 0 then
send "command2"
end if
| Top |
|
Posted by
| Karl_Newbie
USA (23 posts) Bio
|
Date
| Reply #3 on Thu 26 Aug 2004 05:28 PM (UTC) Amended on Thu 26 Aug 2004 05:31 PM (UTC) by Karl_Newbie
|
Message
| Thanks Flannel and Jlzink. I was getting an error with yours, Flannel. But Jlzink's worked great. Lots of new ideas on how to use this now, thanks.
If anyone reads this, I'm trying to save from opening a new thread, how do I expand a variable inside a timer?
"Drink sip from @activecontainer" for example?
There is no expand variable option listed under timers.
It is sort of like this
----
send "drink sip from (getvariable("activecontainer"))"
----
heh?
I'll get it someday. | Top |
|
Posted by
| Flannel
USA (1,230 posts) Bio
|
Date
| Reply #4 on Thu 26 Aug 2004 08:13 PM (UTC) |
Message
| send "get sip from " & getvariable("activecontainer")
and send to: script.
Or, you can have an alias (which will expand variables), and then the timer sends the alias text (with send to execute).
My earlier errors were probably with the "&" they should be "AND", I was crossing my languages.
You can also use Select Case (for multiple if thens) if you have a long list of possible outcomes. (look in the VBScript Docs) |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | Top |
|
Posted by
| Karl_Newbie
USA (23 posts) Bio
|
Date
| Reply #5 on Fri 27 Aug 2004 07:50 PM (UTC) |
Message
| "My earlier errors were probably with the "&" they should be "AND", I was crossing my languages."
Correct :)
Yah, Learning some VBscript might help me, but you good people make it too easy to avoid those docs. | Top |
|
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
16,695 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top