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
➜ Tips and tricks
➜ Multiple "Select Case spell" off one Sub routine
|
Multiple "Select Case spell" off one Sub routine
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
Pages: 1
2
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #15 on Tue 19 Oct 2004 06:20 AM (UTC) |
| Message
| OK, but this looks far too complicated:
For Each v In world.GetVariableList
value = world.GetVariable (v)
If Left (v, 11) = "affliction_" Then
spell = Mid (v, 12)
If value = "on" Then
Select Case spell
Case "herbone" world.sendpush "***TESTone***"
Case "herbtwo" world.sendpush "***TESTtwo***"
End Select
Exit Sub
End If
end if
next
You are looping through all variables, just looking for two exact ones. It would be a lot shorter and easier to read to do this:
if GetVariable ("affliction_herbone") = "on" Then
send "TestOne"
end if
if GetVariable ("affliction_herbtwo") = "on" Then
send "TestTwo"
end if
And, you don't need two subs to do two things, just do two things in the one sub.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Natasi
(79 posts) Bio
|
| Date
| Reply #16 on Tue 19 Oct 2004 03:05 PM (UTC) |
| Message
| | Thank you for the help Flannel and Nick. This has helped me understand alot more and it works now. | | Top |
|
| Posted by
| Natasi
(79 posts) Bio
|
| Date
| Reply #17 on Sun 24 Oct 2004 06:53 PM (UTC) |
| Message
| | I have everything working now but every so often, like if a Sub gets looped somehow and I end up repeating the same action alot, the client freezes up on me and kicks me from the realm. Is there a way to stop this? | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #18 on Sun 24 Oct 2004 10:17 PM (UTC) |
| Message
| There is no way to stop a script once it starts, control is handed over to the script engine (eg. VBscript). The only way is to code so that loops don't happen.
Once properly debugged this shouldn't be happening to you, after all, every loop in a script should have a way to terminate. If there is a place you can't otherwise work out how to do it, you could try this:
counter = 0
while (some condition)
' blah blah - do things here
counter = counter + 1
if counter > 1000 then exit sub
wend
But you are really better off looking at where it is happening and stopping the real problem. |
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|
| Posted by
| Gore
(207 posts) Bio
|
| Date
| Reply #19 on Wed 01 Dec 2004 04:08 PM (UTC) Amended on Wed 01 Dec 2004 04:09 PM (UTC) by Gore
|
| Message
| Although this is an old post.. figured I might put my 2 cents in and try and suggest an easier way for you, Natasi (if, you ever ready this post hehe)
What you might want to try, because when you are healing completely via script, is to keep all your variables scripted, instead of client side variables.
For instance,
Dim aeon
Dim paralyse
Sub Aeon_Log (name, output, wildcard)
aeon = 1 ' 1 = true, which means you have aeon
End Sub
Sub Aeon_cure (name, output, wildcard)
aeon = 0 ' 0 = false, which means you don't have aeon
End Sub
Sub Paralyse_Log (name, output, wildcard)
paralyse = 1
End Sub
Sub Paralyse_Cure (name, output, wildcard)
paralyse = 0
End Sub
Sub Heal_me (name, output, wildcard)
If aeon = 1 then ' if you have aeon then..
World.send "smoke pipe" ' to cure aeon
Elseif paralyse = 1 then ' If you don't have aeon,
' but have paralysis then:
World.Send "eat bloodroot" ' to cure paralyse
End If
End Sub
In my opinion, a lot better, or atleast easier to understand than case statements.
I may be wrong though! | | 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.
69,207 views.
This is page 2, subject is 2 pages long:
1
2
It is now over 60 days since the last post. This thread is closed.
Refresh page
top