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
➜ reg expression and variables
|
reg expression and variables
|
It is now over 60 days since the last post. This thread is closed.
Refresh page
| Posted by
| Neverwhere
USA (40 posts) Bio
|
| Date
| Wed 25 Jun 2003 08:20 AM (UTC) |
| Message
| ok. I know some about reg expressions and triggers sending to variables. Is it possible to send two unique reg expressions to two unique variables in same trigger??
Ex:
Hp:(\d*)/(\w*) Sp: (\d*)/(\w*)
%1,%3 need to be retrieved and sent to different variables.
I know i can send them to one variable, but can we split them up in scripts? |
ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you. | | Top |
|
| Posted by
| Bobble
Canada (76 posts) Bio
|
| Date
| Reply #1 on Wed 25 Jun 2003 02:00 PM (UTC) |
| Message
| I think you'd need to use a script. Lets call the two variables you're using var1 and var2 (I know, I'm so clever).
sub nameofsub (a, b, c)
world.setvariable "var1", c(1)
world.setvariable "var2", c(3)
end sub
That should do it.
|
Open the watch. | | Top |
|
| Posted by
| Neverwhere
USA (40 posts) Bio
|
| Date
| Reply #2 on Wed 25 Jun 2003 07:26 PM (UTC) Amended on Wed 25 Jun 2003 07:34 PM (UTC) by Neverwhere
|
| Message
| what does a&b do then?
plus you cant just send directly to script, must be sent to something first (unless im missing something...) |
ChaosMUD: chaosmud.org:23
Always looking for new players/coders. Willing to train if your willing to lear. Contact Neverwhere or just mention that I sent you. | | Top |
|
| Posted by
| Flannel
USA (1,230 posts) Bio
|
| Date
| Reply #3 on Wed 25 Jun 2003 09:47 PM (UTC) |
| Message
| If you have a script (in the box on the edit, a script name) you do not need to send anything anywhere.
Sub A_Sub_Routine (a, b, c)
End Sub
a is the Name of the Trigger/Alias that sent it, B is the Line (the whole thing that was matched) and C is the array of variables, thats why youll usually see them like this instead Where the s's stand for String and ary is for array.
And, you COULD put the code in the Send Box, and then send to script (which gets rid of the need to make a subroutine in a seperate script file, etc etc)
world.setvariable "var1", %1
world.setvariable "var2", %3
In your send box, and then send to Script |
~Flannel
Messiah of Rose
Eternity's Trials.
Clones are people two. | | Top |
|
| Posted by
| Bobble
Canada (76 posts) Bio
|
| Date
| Reply #4 on Wed 25 Jun 2003 10:08 PM (UTC) |
| Message
|
Quote: And, you COULD put the code in the Send Box, and then send to script (which gets rid of the need to make a subroutine in a seperate script file, etc etc)
world.setvariable "var1", %1
world.setvariable "var2", %3
In your send box, and then send to Script
Just out of curiosity, does anyone know if this is faster than specifying it formally in a script file? |
Open the watch. | | Top |
|
| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Date
| Reply #5 on Thu 26 Jun 2003 07:22 AM (UTC) |
| Message
| I think the script file would be marginally faster, because the script file is parsed once, and then the sub in it is called when needed, whereas using the "send to script" method means it must be parsed every time.
However the time difference may not be very great. |
- 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.
22,217 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top