Register forum user name Search FAQ

Gammon Forum

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 Natasi   (79 posts)  Bio
Date Mon 18 Oct 2004 09:00 AM (UTC)
Message
Ok, I'm trying to set up a balance that is called off one trigger and seperates the Salve and Herb healing so that it will cure only ONE salve affliction and ONE herb affliction. I think I have the basics down and have listed what I've done.


Sub Diagcheck (a, b, c)
Dim value, spell, anorexia, aeon
anorexia = world.getvariable ("affliction_anorexia")
aeon = world.getvariable ("affliction_aeon")
If aeon = "on" Then
Exit Sub
end if
If anorexia = "on" Then
exit sub
end if
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
End If
Next
For Each v In world.GetVariableList
If value = "on" Then
Select Case spell
Case "salveone" world.sendpush "***testthree***"
Case "salvetwo" world.sendpush "***testfour***"
End select
Exit Sub
End If
end if
next
end sub

So, let's say, I'm trying to get "herbone" and "salveone" to be cured while even if the others need to be cured aswell, but need to wait. Thanks for any help you guys can give!

Top

Posted by Natasi   (79 posts)  Bio
Date Reply #1 on Mon 18 Oct 2004 06:21 PM (UTC)
Message
Another wya I can think of this working is if the trigger could call more than one sub routine. Is that possible?
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #2 on Mon 18 Oct 2004 07:29 PM (UTC)
Message
Just make a subroutine, and then call it.

If you want to do it from inside that sub, just make another one, such as:

NewSub(anything you want to pass to it)
Stuff
End Sub

and then call it from inside that other sub by calling:

NewSub(the stuff you pass)


~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Natasi   (79 posts)  Bio
Date Reply #3 on Mon 18 Oct 2004 07:55 PM (UTC)
Message
So, it would look like this then? I'm still new to these sub routines, sorry.

Sub Diagcheck (a, b, c)
Dim value, spell, anorexia, aeon
anorexia = world.getvariable ("affliction_anorexia")
aeon = world.getvariable ("affliction_aeon")
If aeon = "on" Then
Exit Sub
end if
If anorexia = "on" Then
exit sub
end if
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
End If
Next
Sub Diagcheck2 (a, b, c)
For Each v In world.GetVariableList
If value = "on" Then
Select Case spell
Case "salveone" world.sendpush "***testthree***"
Case "salvetwo" world.sendpush "***testfour***"
End select
Exit Sub
End If
end if
next
end sub
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #4 on Mon 18 Oct 2004 08:02 PM (UTC)

Amended on Mon 18 Oct 2004 08:06 PM (UTC) by Flannel

Message
No, you have a subroutine in a subroutine, they are seperate entities.

Sub DiagCheck (a,b,c) 'this is called from MC
'Stuff to do in this sub
Routine1 (height,width) 'we are calling the other sub, we COULD type "call routine1 (height,width)" but the call can be omitted.
End Sub

Sub Routine1 (height, width) 'this is a sub called on its own.
send "the area is " & height * width
end sub

If you have the script reference (Windows Scripting Host help file), which is linked to if you go to the mushclient forums, then the Script functions, then script engines you can download, its the third one, you can search "sub" and call and such.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Natasi   (79 posts)  Bio
Date Reply #5 on Mon 18 Oct 2004 08:41 PM (UTC)
Message
Thanks for the help so far Flannel, I dl'd the file and I'm going through it, but there's alot there to learn. I made another attempt and either I'm missing the point or I'm think headed but I still can't get it to work. This is what I'm at now...I have the Sub called from MC and at the end the CALL Routine1....*it wouldn't let me put in ()*

Sub herbhealing (a, b, c)
Dim value, spell, anorexia, aeon
anorexia = world.getvariable ("affliction_anorexia")
aeon = world.getvariable ("affliction_aeon")
If aeon = "on" Then
Exit Sub
end if
If anorexia = "on" Then
exit sub
end if
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 "stupidity" world.sendpush "***TESTSTUPID***"
Case "slickness" world.sendpush "***TESTSLICK***"
End Select
Exit Sub
End If
end if
next
routine1
end sub

Sub rountine1 (a, b, c)
Dim value, spell, anorexia, aeon
anorexia = world.getvariable ("affliction_anorexia")
aeon = world.getvariable ("affliction_aeon")
If aeon = "on" Then
Exit Sub
end if
If anorexia = "on" Then
exit sub
end if
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 "stupidity" world.sendpush "***TESTSTUPID***"
End Select
Exit Sub
End If
end if
next
end sub
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #6 on Mon 18 Oct 2004 08:54 PM (UTC)
Message
You need to put in three arguements. Since thats what it's expecting. (its 'expecting' the name, the line, and an array of wildcards, but it could be any three arguements).

and in your subroutine called routine1, you mistyped. Youre calling "routine1" but your sub is named "rountine1".

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Natasi   (79 posts)  Bio
Date Reply #7 on Mon 18 Oct 2004 08:59 PM (UTC)
Message
Error number: -2146827244
Event: Execution of line 70 column 19
Description: Cannot use parentheses when calling a Sub
Line in error:
routine1 (a, b, c)
Called by: Immediate execution

That what I keep getting when putting that before the end sub part
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #8 on Mon 18 Oct 2004 09:02 PM (UTC)
Message
Ah.
When you use call, you use parenthesis, when you dont use call, you omit the parenthesis:

Call MyProc(firstarg, secondarg)
MyProc firstarg, secondarg

Do the exact same thing.

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Natasi   (79 posts)  Bio
Date Reply #9 on Mon 18 Oct 2004 09:11 PM (UTC)
Message
ok, I'm not getting errors anymore. When the variable for an affliction in the Sub Herbhealing is on then it trys to cure it, which is good. Now, when I have an affliction in the Sub Routine1 area "on" then nothing is cured, nothing from the Herbhealing or Routine1 sub cure.
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #10 on Mon 18 Oct 2004 09:34 PM (UTC)
Message
I guess Im just not following. Whats the problem?

Isnt it the same code in both routines?

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
Top

Posted by Natasi   (79 posts)  Bio
Date Reply #11 on Mon 18 Oct 2004 09:46 PM (UTC)

Amended on Tue 19 Oct 2004 01:36 AM (UTC) by Nick Gammon

Message
Ok, saying the in my variables section I have "herbone" "on", "herbtwo" "on", "salveone" "on", "salvetwo" "off".
Now, In order to seperate Herb and Salve balance I need this Sub to cure one of the "herb" afflictions and one of the "salve" afflictions, but ONLY one of each. Seeing as how the variables are set I currently have 2 herb afflictions and one salve. After calling the Sub I should cure one of each elaving me with one herb affliction after.
With the way I have the sub now it only cures one of the herb afflictions and doesn't even seem to notice the salve afflictions. Here is the last Sub as I had it


Sub herbhealing (a, b, c)
Dim value, spell, anorexia, aeon
anorexia = world.getvariable ("affliction_anorexia")
aeon = world.getvariable ("affliction_aeon")
If aeon = "on" Then
Exit Sub
end if
If anorexia = "on" Then
exit sub
end if
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
routine1 a, b, c
end sub

Sub routine1 (a, b, c)
Dim value, spell, anorexia, aeon
anorexia = world.getvariable ("affliction_anorexia")
aeon = world.getvariable ("affliction_aeon")
If aeon = "on" Then
Exit Sub
end if
If anorexia = "on" Then
exit sub
end if
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 "salveone" world.sendpush "***TESTthree***"
Case "salvetwo" world.sendpush "***TESTfour***"
End Select
Exit Sub
End If
end if
next
end sub


Again, I'm sorry for any irritation this may have caused
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #12 on Tue 19 Oct 2004 01:42 AM (UTC)
Message
I've added [code] to your post to show the indenting, which unforunately is not very much.

It is much easier to read if you indent things like ifs, like this:


If anorexia = "on" Then
  exit sub
end if


It isn't clear what you are trying to do here. You have two virtually identical subs, and one calls the other. Why do that?

Are you thinking about what the code is doing? For instance, in the herbhealing sub you have the above test (if anorexia = "on") and if it is "on" then you exit the sub. Thus you will never call routine1, but in routine1 you also test if anorexia is on. Why?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Natasi   (79 posts)  Bio
Date Reply #13 on Tue 19 Oct 2004 03:04 AM (UTC)
Message
I'm trying to set a call for when I use DIAG to check my afflictions. The thing though is I am using the "You are:" to send a reset clearing all affliction variables to off then the afflictions listed under the "You are:" will turn their respective variables back to on and then when I recover equilibrium a call will be sent to the Sub Herbhealing so it can start curing the afflictions.

The reason I have two Sub routines is because I need to have different afflictions covered so that I can maintain HERB and SALVE balance. If I can call multiple Subs from just one triggerthat would be best, but I can't as far as I know.

The second part checking Aeon was a mistake, it wasn't supposed to be there
Top

Posted by Flannel   USA  (1,230 posts)  Bio
Date Reply #14 on Tue 19 Oct 2004 04:36 AM (UTC)
Message
You can call two subs from the same trigger.

Send to: Script
and then call them just like you called routine1.

So your send text would be:
call routine1 (stuff)
call routine2 (stuff)

~Flannel

Messiah of Rose
Eternity's Trials.

Clones are people two.
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.


53,269 views.

This is page 1, subject is 2 pages long: 1 2  [Next page]

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.