Register to post in forums, or Log in to your existing account
 

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » CMUD General Discussion
draguneater
Newbie


Joined: 04 Sep 2006
Posts: 7

PostPosted: 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.
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4689
Location: Pensacola, FL, USA

PostPosted: Mon May 24, 2010 9:57 pm   
 
#TR {^~[Exits: (*)~]} {rmexits=%1}
_________________
Discord: Shalimarwildcat
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: 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
Reply with quote
draguneater
Newbie


Joined: 04 Sep 2006
Posts: 7

PostPosted: Mon May 24, 2010 10:10 pm   
 
Thanks Shalimar, that worked perfectly Very Happy
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » CMUD General Discussion All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© 2009 Zugg Software. Hosted by Wolfpaw.net