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!
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
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.
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
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".
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
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.
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
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?
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
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.
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?
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.
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.