What I want is to have an array that notifies me at a stage of a certain attack. so here's everything please tell me whats wrong.When I try I it says it can't ivoke the sub.
Sub:
sub Cleave (name,output,wildcs)
Dim Cleave(2)
Cleave = split(name, "_")
Select Case Cleave(2)
Case "0"
World.note "First stage"
Case "1"
World.note "Second stage"
End Select
end sub
----------------------------------------------------------
Triggers:
<trigger
enabled="y"
match="* begins to bear down on you with his whirling a * * *."
name="trigger_cleave_1"
script="Cleave"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="* raises his a * * * over his head and begins to swing it in a wide circle, gaining speed as he goes."
name="trigger_cleave_0"
script="Cleave"
sequence="100"
>
</trigger>
------------------------------------------------------------
1) I am not completely sure about this, as I always tried to avoid such sort of conflicts, but you have a variable - the Cleave array - and a sub with the same name. Might want to change this
2) Your triggers might not be matching, best to simplify it like this:
<trigger
enabled="y"
match="* begins to bear down on you with * whirling *"
name="trigger_cleave_1"
script="Cleave"
sequence="100"
>
</trigger>
<trigger
enabled="y"
match="* raises * over * head and begins to swing it *"
name="trigger_cleave_0"
script="Cleave"
sequence="100"
>
</trigger>
I tried what you said, but I still can't get it to work. here's what is says:
Error Number:-214682875
Event: Execution of line 10 colomn 1
Description: Type Mismatch
Called by: Function/Sub: Behead called by trigger
Reason: processing trigger "trigger_cleave_1"
------------------------------------------------------------
Unable to invoke script subroutine "Behead" when processing trigger "trigger_cleave_1"
-----------------------------------------------------------
P.S Cleave is now Behead
Umm.. When you use split, you can't pre-dim the variable. In other words the line 'DIM Cleave(2)' is telling the script to create an array than goes from 0 to 1, then you try to 'split' the name into an array with 3 elements. Even if you made it 'DIM Cleave(3)' it may not work, since that is a fixed size and split may only work with variants, since it needs to define the size of the array when it does the split itself. Just change 'DIM Cleave(2)' to 'DIM Cleave' and it should work.
One simple thing would be to have two trigger subs, then you don't need to pull apart the name to find which trigger called you.
A second one would be to do a simple test:
if name = "trigger_cleave_0" then
world.note "First stage"
else
world.note "Second stage"
end if
A third approach would be to test the only thing in the name that changes, eg.
if right (name, 1) = "0" then
world.note "First stage"
else
world.note "Second stage"
end if
Finally, as Shadowfyr and Ked said, don't re-use the sub name as a variable, and don't pre-dim it.
sub Cleave (name,output,wildcs)
Dim splitname
splitname = split(name, "_")
Select Case splitname (3)
Case "0"
World.note "First stage"
Case "1"
World.note "Second stage"
End Select
end sub
Also, can you please give your forum posts a more meaningful topic name? "Please help me" doesn't help anyone browsing the forum to know what the post is about, and a lot of us will try to help you anyway. A better topic name would be something like "Problem with using split in a sub" or "How do I find which trigger called a sub".
Ok. I have another problem. I'm basically trying to do what I did before, however something a bit more complex. What I basically want to achieve is a curing system, I ge thit with this and this, and it makes a variable (aconite for example) go to vbtrue, then when its cured i have it go to vbfalse, then I also have a 1 second timer, that does if statements if aconite then outb goldenseal eat goldenseal for example. However when I try this it doesn't seem to even respond, and when it does, it says something like unable to invoke subroutine healing when proccessing Afflic_AConite_1.
------------------------------------------------------------
Subs:
this is the main healing sub:
Dim Curare, Aconite, Darkshade, Vernalius, Prefarar, Eurypteria, Kalmia
Sub Healing (name,output,wildcs)
Dim TempArray
TempArray = split(name, "_")
Select Case TempArray(0)
Case "Cured"
Select Case TempArray(1)
Case "Curare"
world.SetVariable "Curare", "VbFalse"
Case "Aconite"
world.SetVariable "Aconite", "VbFalse"
Case "Darkshade"
world.SetVariable "Darkshade", "VbFAlse"
Case "Vernalius"
world.SetVariable "Vernalius", "VbFalse"
Case "Prefarar"
world.SetVariable "Prefarar", "VbFalse"
Case "Eurypteria"
world.SetVariable "Eurypteria", "VbFalse"
Case "Kalmia"
world.SetVariable "Kalmia", "VbFalse"
End Select
Case "Afflic"
Select Case TempArray(1)
Case "Curare"
world.SetVariable "Curare", "VbTrue"
Case "Aconite"
world.SetVariable "Aconite", "VbTrue"
Case "Darkshade"
world.SetVariable "Darkshade", "VbTrue"
Case "Vernalius"
world.SetVariable "Vernalius", "VbTrue"
Case "Prefarar"
world.SetVariable "Prefarar", "VbTrue"
Case "Eurypteria"
world.SetVariable "Eurypteria", "VbTrue"
Case "Kalmia"
world.SetVariable "Kalmia", "VbTrue"
End Select
End Select
End sub
this is the sub for the timer:
Sub Timer (name)
if aconite then
outb goldenseal
eat goldenseal
elseif darkshade then
outb ginseng
eat ginseng
elseif curare then
outb bloodroot
eat bloodroot
elseif kalmia then
outb kelp
eat kelp
elseif prefarar then
outb kelp
eat kelp
elseif eurypteria then
outb lobelia
eat lobelia
elseif vernalius then
outb kelp
eat kelp
end if
end sub
------------------------------------------------------------
Trigs:
<trigger
enabled="y"
match="Hmmmm. Why must everything be so difficult to figure out?"
name="Afflic_Aconite_1"
script="Healing"
sequence="100"
>
</trigger>]
-----------------------------------------------------------
Timer:
<timer script="Timer" enabled="y" second="1" >
Ok. I adapted some of it. like the world.getvariable part. however, it still, doesn't even respond, and I"v checked a million times and trigger Hmmm. Why is everyting difficult to figure out? matches.
Please help.
Well, for one, the Timer sub will never work since as of now it doesn't do anything. If you are trying to send something to the world you need to use world.send "".
So it's not:
"outb bloodroot"
but rather:
world.send "outb bloodroot"
Also, why are using MC variables when you have already declared vbscript ones? There's no sense in having:
Ok. Thank Nick, however I another question.
First thing, in the if, if I make it vbtrue and all that,
should I type
If Curare then
send.world "outb bloodroot"
send.world "eat bloodroot"
-----------------------------------------------------------
Or should it be:
If world.getVariable("Curare") = "Vbtrue" Then
"
"
I had no idea you could set MC variables to boolean values... Now if I only got around to testing whether it's possible to call the main script through world.callplugin, using the world's id... *daydream*
MUSHclient variables are stored internally as strings, so when you get it back it will be a string (eg. "0") and not a number (eg. 0). However you might use CInt to convert the result from a string to a number.
A quick test shows this works anyway:
/if "0" then world.note "hello" ' displays nothing
/if "1" then world.note "hello" ' displays hello
Thus, you can use "0" or "1" without converting them to 0 and 1. It might be worth noting that vbTrue is actually -1, not 1. However, anything non-zero is considered true.
Which is why, by the way, this would *not* work:
world.setvariable "test", "vbFalse"
if world.GetVariable ("test") then
...
end if
Since the string "vbFalse" is not zero, the code *would* be executed.