|
draguneater Newbie
Joined: 04 Sep 2006 Posts: 7
|
Posted: Mon May 24, 2010 9:19 pm
Script help plz: Capturing a line and populating a variable with it |
Hi folks,
Short explanation: I need to capture a line and populate a variable with the contents so that it can be reported to a channel. The string will always be the room exits and will appear similar to, "[Exits: north east south (west)]" where west is a locked door. The variable name is @rmexits and I'd like to trigger the capture off of ^[Exits:
Any help appreciated. |
|
|
|
shalimar GURU
Joined: 04 Aug 2002 Posts: 4691 Location: Pensacola, FL, USA
|
Posted: Mon May 24, 2010 9:57 pm |
#TR {^~[Exits: (*)~]} {rmexits=%1}
|
|
_________________ Discord: Shalimarwildcat |
|
|
|
MattLofton GURU
Joined: 23 Dec 2000 Posts: 4834 Location: USA
|
Posted: Mon May 24, 2010 9:58 pm |
Assuming that you want to do the work, what part(s) are you having trouble with?
1)pattern.
a)You already know how to use ^ to match the beginning of the line.
b)Do you know how to use ~ to prevent CMud from interpreting special characters (in this case, [] and ())? All you do is ~[ and so on.
c)to match letters, spaces, and (), you can use the range pattern: [%w%s~(~)]
d)to capture the pattern to a %1...%99 variable so you can assign it to @rmexits, surround it with ()
2)code.
a)variable assignment. Easiest way is to use a=b syntax. A is equal to the variable name without the @. More complex examples (though not needed in this case), can be used with the #VARIABLE command. |
|
_________________ EDIT: I didn't like my old signature |
|
|
|
draguneater Newbie
Joined: 04 Sep 2006 Posts: 7
|
Posted: Mon May 24, 2010 10:10 pm |
Thanks Shalimar, that worked perfectly
|
|
|
|
|
|