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
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Fri Jan 09, 2009 12:10 am   

#tag problem - Reverse of %s?
 
Hi,
my rooms are captured by the following pattern: &Roomname ~[&Roomexits~] (e.g. Throneroom [n,e,move throne]).
I have a problem as some special items in the rooms cause errors in the capturing (e.g. Bulletin Board [ 20 messages ], -> the "20 messages" comes with blank spaces at the beginning and end).

Is there a way to capture the normal room without firing on the bulletin board message? Possibly by "reversing" %s?

I tried the {^%s} pattern but that one does not help (Error in trigger pattern: {^%s} lookout assertion is not fixed length (17))
and the
&%x{roomexits} -> this one cannot cope with 2 word exits
Reply with quote
ReedN
Wizard


Joined: 04 Jan 2006
Posts: 1279
Location: Portland, Oregon

PostPosted: Fri Jan 09, 2009 12:19 am   
 
You can do this with a regex. You'd insert this optionally matched string where ever it might appear in your normal string. The question mark at the end means the whole thing either matches once or zero times. So if it isn't there, it doesn't match. If it is there, then it will match:

(?:[\s*\d+\s+messages\s*])?
Reply with quote
Ghedemonas
Novice


Joined: 15 Aug 2007
Posts: 39

PostPosted: Tue Jan 27, 2009 7:37 pm   
 
Hi, I solved it as follows - I tried the regex but I fear I have no experience with it, so I failed ..
Instead, I found a "walkaround" without regex.
Thanks nontheless ReedN!

<trigger name="Roomcapture" priority="597940" id="1306">
<pattern>^(*) ~[(*)~].$</pattern>
<value>#noop ***Checking, if the Room is actually a Message Board***
#if ((%2 =~ " (%d) notes ") OR (%2 =~ " (%d) messages ") OR (%2 =~ " (%d) note ") OR (%2 =~ " (%d) message "))
{#noop Ignore the Bulletin Board} {
#noop ***********Room found-Checking if the Room is a pool********
Mapper.Roomname = %replace(%1," (Abyssal)",)
Mapper.Roomname = %replace(@Mapper.Roomname," (Deep)",)
Mapper.Roomname = %replace(@Mapper.Roomname," (Shallow)",)
Mapper.Roomname = %replace(@Mapper.Roomname," (Empty)",)
#sub {%ansi(white)%1 %ansi(green)[%2]}
Mapper.Roomexits = %2
#TAG name @Mapper.Roomname ~[@Mapper.Roomexits~]
#TAG exit @Mapper.Roomexits
#ok
}</value>
</trigger>
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Thu Jan 29, 2009 11:58 am   
 
I too would suggest a regex. The simplest being:
^(.*) ~[(( ?\d+ (?:notes?|messages?) ?)|.*)~].$
This pattern causes the regex to try to match the various notes and messages entries, when found it creates an additional capture. If it can't then it permits a general match capturing all of it.

You can then change your line:
#if ((%2 =~ " (%d) notes ") OR (%2 =~ " (%d) messages ") OR (%2 =~ " (%d) note ") OR (%2 =~ " (%d) message "))
{#noop Ignore the Bulletin Board} {
to
#IF (%3) {#noop Ignore the Bulletin Board} {

I would also suggest not using #NOOP for comments. This is a very practice from zMud; and will slow down the execution of your scripts considerably. CMud supports proper comments using //.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
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