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
Xarsas
Beginner


Joined: 05 Mar 2008
Posts: 16

PostPosted: Thu Oct 15, 2009 6:48 pm   

Exact Trigger Pattern match/#SUB and MXP
 
Hi,

I want to sub my normal directions in rooms with a line of directions that are clickable, however when setting up a #sub trigger on for instance "north" it will trigger on northeast or northwest as well, and when combined with "west" and :east" i end up having "northeast" that exsists of two mxp patterns "north"+"east" for instance.
I have set up a trigger as follows :
Code:

<trigger priority="1040" regex="true" id="104">
  <pattern>You see exits leading (\w*).?\s*(\w*).?\s*(\w*).?\s*(\w*).?\s*(\w*).?\s*</pattern>
  <value><![CDATA[#sw (%1=north) {#SUB {<send 'North|swim North' 'North|Swim North'>North</send>}}
   (%1=northeast) {#SUB {<send 'Northeast|swim Northeast' 'Northeast|Swim Northeast'>Northeast</send>}}
   (%1=east) {#SUB {<send 'East|swim East' 'East|Swim East'>East</send>}}
   (%1=southeast) {#SUB {<send 'southeast|swim southeast' 'Southeast|Swim southeast'>southeast</send>}}
   (%1=south) {#SUB {<send 'South|swim South' 'South|Swim South'>South</send>}}
   (%1=southwest) {#SUB {<send 'southwest|swim southwest' 'Southwest|Swim southwest'>southwest</send>}}
   (%1=west) {#SUB {<send 'West|swim West' 'West|Swim West'>West</send>}}
   (%1=northwest) {#SUB {<send 'Northwest|swim Northwest' 'Northwest|Swim Northwest'>Northwest</send>}}
   (%1=in) {#SUB {<send 'In|swim In' 'In|Swim In'>In</send>}}
   (%1=out) {#SUB {<send 'Out|swim Out' 'Out|Swim Out'>Out</send>}}
   (%1=up) {#SUB {<send 'Up|swim Up' 'Up|Swim Up'>Up</send>}}
   (%1=down) {#SUB {<send 'Down|swim Down' 'Down|Swim Down'>Down</send>}}
#sw (%2=north) {#SUB {<send 'North|swim North' 'North|Swim North'>North</send>}}
   (%2=northeast) {#SUB {<send 'Northeast|swim Northeast' 'Northeast|Swim Northeast'>Northeast</send>}}
   (%2=east) {#SUB {<send 'East|swim East' 'East|Swim East'>East</send>}}
   (%2=southeast) {#SUB {<send 'southeast|swim southeast' 'Southeast|Swim southeast'>southeast</send>}}
   (%2=south) {#SUB {<send 'South|swim South' 'South|Swim South'>South</send>}}
   (%2=southwest) {#SUB {<send 'southwest|swim southwest' 'Southwest|Swim southwest'>southwest</send>}}
   (%2=west) {#SUB {<send 'West|swim West' 'West|Swim West'>West</send>}}
   (%2=northwest) {#SUB {<send 'Northwest|swim Northwest' 'Northwest|Swim Northwest'>Northwest</send>}}
   (%2=in) {#SUB {<send 'In|swim In' 'In|Swim In'>In</send>}}
   (%2=out) {#SUB {<send 'Out|swim Out' 'Out|Swim Out'>Out</send>}}
   (%2=up) {#SUB {<send 'Up|swim Up' 'Up|Swim Up'>Up</send>}}
   (%2=down) {#SUB {<send 'Down|swim Down' 'Down|Swim Down'>Down</send>}} etc.


but all that does is run through them all and then take the last direction and subs that and displays it correctly.

a sample of what the line from the mud looks is
Code:

You see exits leading north, southeast, southwest and northwest.


can someone help me straight here please? Smile
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Oct 15, 2009 7:59 pm   
 
#sub will substitute the entire line, so it is natural that the last #sub will be the only one that actually shows. You need to do something much trickier.

The first idea that comes to my mind is to have a normal trigger (not regex) with a pattern "You see exits leading (*)." Then you do some replacements on %1 to convert it into a stringlist of directions. Next you do a loop over all elements of the stringlist, building up your substitution line by appending the appropriate string segments for each matching direction. Finally you do your #sub.

It would look something like this:
Code:

#local $directions $subline
$directions = %replace(%replace(%1,", ","|")," and ","|")
#forall $directions {
  #switch (%i)
    ("north") {$subline = %concat($subline," <send 'North|swim North' 'North|Swim North'>North</send>"}
    ("west") {$subline = %concat($subline," <send 'West|swim West' 'West|Swim West'>West</send>"}
    [etc...]
  }
}
#sub $subline

If your substitutions are really as simple as the example you gave, you might be able to get rid of the #switch and create each substring directly from the name of the direction.
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