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
Guest






PostPosted: Mon May 26, 2014 10:55 pm   

How do I use a word from the last line received in a trigger?
 
Say for example I receive this line from a world:

Bob pages, "Hello there." to you.

I want to get the name of the person that sent the page.

The name of the person will always be the first word on the line.

Then I want to open the page in another window titled "Page - Bob".

I know how to trigger based on a word in a line and I know how to send text to another window. But how do I get the word "Bob" at the start of the line into a variable?
Reply with quote
mikeC130
Wanderer


Joined: 03 Jul 2006
Posts: 85

PostPosted: Tue May 27, 2014 5:45 pm   
 
Assuming that the name is only one word, you can use the wildcard %w to match it, and enclose it in parentheses to capture it.

So the basic trigger line would be:
Code:

(%w) pages, "

and the name you are looking for would be stored in %1, which you then assign to a variable if you want to use it later, or use it directly. In order to capture both the name and the actual page, just capture the rest of the line with an (*). You can get rid of the end quote by using it at the end of your trigger, like so.

Code:
(%w) pages, "(*)"


and now the name will be in %1 and the page in %2.

Except, I do believe that the " is a special character, so it won't capture correctly. Use the ~ to force it to capture the quote, and your trigger should be:

Code:
(%w) pages, ~"(*)~"


You then only need to create the window using %1 and send %2 to it.

Mike


EDITED: because I can't tell the difference between a leading and trailing %


Last edited by mikeC130 on Tue May 27, 2014 7:33 pm; edited 2 times in total
Reply with quote
Daern
Sorcerer


Joined: 15 Apr 2011
Posts: 809

PostPosted: Tue May 27, 2014 7:25 pm   
 
The wildcard is actually %w, not w% - see the Pattern Matching documentation.
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