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
➜ General
➜ Subs
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Rhinoa
United Kingdom (37 posts) Bio
|
Date
| Wed 30 Jan 2002 12:52 PM (UTC) |
Message
| Hi :)
Is there a way to call subs into other subs..?
Like..:
Trigger:
Rhinoa says: Test
Label: Test
Sub: Test
Sub Test (strname, trig_line, arrWildCards)
if arrWildCards (1) = "Test" then
callsub Tester
end sub
Sub Tester (strname, trig_line, arrWildCards)
world.note "Hey, it worked"
end sub
I'm doing something that needs the programming like this, so I can't do it all in 1 sub..
Hope you can help! :)
~Rhinoa~ | Top |
|
Posted by
| Rhinoa
United Kingdom (37 posts) Bio
|
Date
| Reply #1 on Wed 30 Jan 2002 09:37 PM (UTC) |
Message
| Nevermind, I've got it now..
Seems the call bit was right, but I was doing something else wrong with the programming... and since I havn't used call before, I thought it was that, oh well..
~Rhinoa~ | Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #2 on Tue 05 Mar 2002 07:54 AM (UTC) |
Message
| Exactly what did you do to call another sub, I been looking for something like this for a little while, Could you outline how the call funtion works?
Thanks
|
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Tue 05 Mar 2002 08:36 AM (UTC) |
Message
| You could do it two ways:
Tester "blah", "", ""
call Tester ("blah", "", "")
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| David
USA (49 posts) Bio
|
Date
| Reply #4 on Tue 05 Mar 2002 08:50 AM (UTC) |
Message
| A while back I was looking for something like this.
Ok lets see if This resolves my question.
I have Trigger A. with say... 3 wildcards
Trigger a Runs sub 1
However, I want to run wildcard 2 through a different subroutine(why? I don't know but I want to make sure I understand if this is what i want it to do)
Ok so I run wildcard 2 through the other sub getting something new(what I don't know yet but I am sure I will think of something). So now I have wildcard 2 run through sub2 and I continue to run the original sub.
Why this is important to me I forget, but it is LOL
Does that sound like what its supposed to do? |
My code(with a LOT of Nicks help) to fame:
sub OnAutoCombo (TriggerName, TriggerLine, arrWildCards)
dim AutoCombo
AutoCombo = split (arrWildCards (1))
Dim i, attack
for i=lbound (AutoCombo ) to ubound (AutoCombo )
Select Case AutoCombo (i)
case "rp" attack = "punch right"
case "lp" attack = "punch left"
case "s" attack = "sweep"
case "r" attack = "roundhouse"
case else attack = "" ' unknown attack type
End Select
if i = ubound (AutoCombo ) then
world.send "throw " + world.getvariable ("attacker") + " down"
else
world.send attack + " " + world.GetVariable ("attacker")
end if
next
end sub
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #5 on Tue 05 Mar 2002 08:55 PM (UTC) |
Message
| Yes you can do that. It might look like this:
sub do_wildcard_1 (strtext)
world.note strtext ' display it
end sub
sub do_wildcard_2 (strtext)
world.note strtext ' display it
end sub
sub do_wildcard_3 (strtext)
world.note strtext ' display it
end sub
Sub Trigger_sub (strname, trig_line, arrWildCards)
do_wildcard_1 arrWildCards (1)
do_wildcard_2 arrWildCards (2)
do_wildcard_3 arrWildCards (3)
end sub
The above example only displays them, but shows the idea. You can route each wildcard through a different sub if you want to.
The trigger itself calls Trigger_sub.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | 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.
16,801 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top