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
➜ VBscript
➜ If/Then/Else statements; Having trouble
|
If/Then/Else statements; Having trouble
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Kagai
(2 posts) Bio
|
| Date
| Tue 17 Nov 2009 09:00 AM (UTC) |
| Message
| Alright, so I've really gotten into scripting, and my prefered method is using VBscript, easy, simple, I should know the language like the back of my hand. I create a trigger, with not one, but two if statements in it, as follows:
if EKill = "off" then
world.EnableTrigger "Balance", FALSE
else
If eshield = "1" then
world.send "raze @target"
else if eprism = "1" then
world.send "raze @target"
else if ereflect = "1" then
world.send "raze @target"
Else
world.send "wave"
end if
end if
but I go to test it out, and it gives me this error:
Error number: -2146827274
Event: Execution of line 13 column 7
Description: Expected 'End'
Line in error:
end if
Called by: Immediate execution
But, with VB, and VBscript, even, it tries to tell me that it's the wrong way to end an If statement, but when I go and take out the "If" of end if, it gives me this message:
Error number: -2146827276
Event: Execution of line 12 column 5
Description: Expected 'If'
Line in error:
end
Called by: Immediate execution
| | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #1 on Tue 17 Nov 2009 09:34 AM (UTC) Amended on Tue 17 Nov 2009 09:38 AM (UTC) by Nick Gammon
|
| Message
| Well, I count a lot more than 2 ifs there:
if EKill = "off" then
world.EnableTrigger "Balance", FALSE
else
if eshield = "1" then
world.send "raze @target"
else if eprism = "1" then
world.send "raze @target"
else if ereflect = "1" then
world.send "raze @target"
Else
world.send "wave"
end if
end if
You need an "end if" for each if. However, if you make it "elseif" then you don't.
eg.
if EKill = "off" then
EnableTrigger "Balance", vbFalse
else
if eshield = "1" then
Send "raze @target"
elseif eprism = "1" then
Send "raze @target"
elseif ereflect = "1" then
Send "raze @target"
Else
Send "wave"
end if
end if
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Kagai
(2 posts) Bio
|
| Date
| Reply #2 on Tue 17 Nov 2009 09:50 AM (UTC) |
| Message
| | well, I've redesigned the whole thing, and realized I was just wasting my time with the first REAL if statement, and had forgotten that it was Elseif, not Else If. Thanks for the reminder. | | 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,174 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top