[Home] [Downloads] [Search] [Help/forum]


Register forum user name Search FAQ

Gammon Forum

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  General
. . -> [Subject]  Sub Splitting Problems

Sub Splitting Problems

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


Pages: 1 2  

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Fri 04 Apr 2003 02:03 PM (UTC)
Message
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>
------------------------------------------------------------


[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #1 on Fri 04 Apr 2003 02:12 PM (UTC)
Message
ok, I can think of 2 things...

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>



[Go to top] top

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #2 on Fri 04 Apr 2003 02:42 PM (UTC)
Message
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
[Go to top] top

Posted by Shadowfyr   USA  (1,786 posts)  [Biography] bio
Date Reply #3 on Fri 04 Apr 2003 06:07 PM (UTC)
Message
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.
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Fri 04 Apr 2003 08:59 PM (UTC)
Message
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


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #5 on Fri 04 Apr 2003 09:17 PM (UTC)
Message
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".

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #6 on Mon 07 Apr 2003 08:45 AM (UTC)
Message
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" >

</timer>



[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #7 on Mon 07 Apr 2003 07:05 PM (UTC)
Message
Read this thread:
http://www.gammon.com.au/forum/bbshowpost.php?bbsubject_id=2125&page=999999

Exact same project.

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #8 on Mon 07 Apr 2003 08:04 PM (UTC)
Message
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.
[Go to top] top

Posted by Ked   Russia  (524 posts)  [Biography] bio
Date Reply #9 on Tue 08 Apr 2003 08:25 AM (UTC)
Message
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:

Dim aconite, curare ....

and then:

world.setvariable "Aconite", "vbtrue"

why not just do:

aconite = vbtrue
[Go to top] top

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #10 on Tue 08 Apr 2003 11:06 AM (UTC)
Message
ok. I'll get rid of the dim. but I don't get the part with the aconite = vbtrue, can't I just the variable to 1?

[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #11 on Tue 08 Apr 2003 11:16 AM (UTC)
Message
Now that I look at it, your code looks a bit strange. eg.

world.SetVariable "Darkshade", "VbTrue"

You don't quote vbTrue, doing what you have done will put "VbTrue" literally into the variable. It should read:

world.SetVariable "Darkshade", vbTrue

However you are right you could use 1 and 0, however vbTrue and vbFalse is a bit more self-documenting.


- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Morgoth   Israel  (38 posts)  [Biography] bio
Date Reply #12 on Tue 08 Apr 2003 03:17 PM (UTC)
Message
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
"
"

[Go to top] top

Posted by Magnum   Canada  (580 posts)  [Biography] bio
Date Reply #13 on Tue 08 Apr 2003 05:08 PM (UTC)
Message
Use: If Curare then

Get my plugins here: http://www.magnumsworld.com/muds/

Constantly proving I don't know what I am doing...
Magnum.
[Go to top] top

Posted by Nick Gammon   Australia  (22,990 posts)  [Biography] bio   Forum Administrator
Date Reply #14 on Tue 08 Apr 2003 10:13 PM (UTC)
Message
Whatever you do, it has to be consistent with how you set the variable.

eg.



If you do this:


dim Curare
...

case "curare"
Curare = vbtrue
...


Then you test like this:


if Curare then
...
end if





If you do this:


case "curare"
world.setvariable "curare", "vbtrue"
...


Then you test like this:


if world.Getvariable ("curare") = "vbtrue" then
...
end if





If you do this:


case "curare"
world.setvariable "curare", vbtrue
...


Then you test like this:


if world.Getvariable ("curare")  then
...
end if



- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] 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.


45,566 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] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

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

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at HostDash]