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

Play RetroMUD
Post new topic  Reply to topic     Home » Forums » zMUD General Discussion
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Sun Mar 07, 2004 6:29 pm   

Very odd trigger behavior
 
Sad

Apologies in advance for the length of this post.

I have set up triggers for tagging room names, descs, and exits on Achaea as suggested in this forum. One thing that I have not been able to get correct though, is the parsing of the exits, and it's getting to the point of absurdity.

The problem with mapping Achaea as you know is the way the lines are formatted, and the fact that it changes based on whether you are walking into a room or looking while standing still in a room. Another issue that seemed minor but is now refusing to be solved, is that the exits can appear on one, two, or three lines.

My solution to this is to try to parse those lines, keying off of the first one, which contains a unique ansi code. This trigger works fine, but the line after it never seems to be checked for pattern matches. Below are my triggers and variables right after having looked in a room. The log from looking in that room is below that.

As you can see in the log, the trigger which I have labeled "== Room Exits Trigger Line 1 ==>" is firing at the appropriate time, and it then enables the trigger named ExitsN, which I expect to fire any time it encounters a line, so it disables itself when it completes. The problem is that (referring to the log or the contents of the variable RoomExitsRawN, when it fires, it seems to fire on the line before - which was already matched by the trigger that enabled ExitsN). How can this be? How can I fix this so that it fires on the following line?

Any help is greatly appreciated.

Spartacus

#CLASS {MapFormatter}
#VAR RoomDescLine {door reading "Pjeter's Bait and Tackle".}
#VAR RoomName {Fair Seas Lane approaching the marina.}
#VAR RoomDescLineRaw {door reading "Pjeter's Bait and Tackle". A rune resembling a horse has been }
#VAR p {41}
#VAR DirectionsList {north|south|east|west|northeast|southeast|southwest|northwest|up|down|in|out}
#VAR RoomExitsRaw {You see exits leading north (open door), northeast, east (open door), }
#VAR RoomExitsStripped {You|see|exits|leading|north|(open|door)|northeast|east|(open|door)|}
#VAR RoomExits {south east southeast southwest northwest}
#VAR RoomExitsRawN {You see exits leading north (open door), northeast, east (open door),}
#VAR RoomExitsStrippedN {You|see|exits|leading|north|(open|door)|northeast|east|(open|door)}
#VAR RoomDetected {1}
#VAR RoomExitList {north|east|northeast}
#VAR RoomDesc {Fair Seas Lane splits here where it turns into Cliffside Road. The grand houses lining either side of Cliffside to the north east add grandeur to the intersection, while the rocky beach barely visible to the south east adds a bitof relaxed scenery. Tall sails of the many moored ships at the marina can be seen poking out from above the houses that line the street to the south, while on the northern side, nestled among the residences, a small, but tidy shop rests just a few inches back from the pavement. A wooden sign hangs above the door reading "Pjeter's Bait and Tackle".}
#VAR DescTagged {1}
#TRIGGER {^%e[1;30m(*)} {; Room Desc and anything else;#var RoomDescLineRaw {%1} _nodef MapFormatter;#var p %pos({%e~[36m},{@RoomDescLineRaw}) _nodef MapFormatter;#if (@p=0) {#var p %pos({%e~[0~;36m},{@RoomDescLineRaw}) _nodef MapFormatter;#if (@p=0) {#var p %pos({%e~[1~;36m},{@RoomDescLineRaw}) _nodef MapFormatter}};#if (@p>0) {#var RoomDescLine {%stripansi(%left(@RoomDescLineRaw,%eval(@p-1)))} _nodef MapFormatter} {#var RoomDescLine {%stripansi(@RoomDescLineRaw)} _nodef MapFormatter};#if (@RoomDesc) {RoomDesc=%concat(@RoomDesc,@RoomDescLine)} {#var RoomDesc {%concat(@RoomDescLine,' ')} _nodef MapFormatter}} "" {notrig|color}
#TRIGGER {^(%e[30m*.)*(%e[34m*)$} {; room desc + players (ie - end of desc);#var RoomDescLine {%stripansi(%1)} _nodef MapFormatter;; #sub {%1 %cr %2};#if (@RoomDesc) {RoomDesc=%concat(@RoomDesc,@RoomDescLine)} {#var RoomDesc {%concat(@RoomDescLine,' ')} _nodef MapFormatter}} "" {notrig|color}
#TRIGGER {^%e[1;32m(*.)*$} {; Room Name;#var RoomDetected {1} _nodef MapFormatter;#var RoomNameRaw {%stripansi(%1)} _nodef MapFormatter;; Now, if we have a color change, it needs to be stripped out.;#var p {%pos(" (road)",@RoomNameRaw)} _nodef MapFormatter;#if (@p>0) {#var RoomName {%concat(%trimright(%left(@RoomNameRaw,@p)),".")} _nodef MapFormatter} {#var RoomName {@RoomNameRaw} _nodef MapFormatter};#if (!%maplocked()) {#tag name @RoomName};#unvar RoomDesc MapFormatter;#unvar RoomExitList MapFormatter;#unvar RoomNameRaw MapFormatter;#unvar DescTagged MapFormatter;#var RoomExitList {} _nodef MapFormatter} "" {notrig|color}
#TRIGGER {^(%e[36m*.)*(%e[1;30m*)$} {; weather detected;#var RoomDescLine {%stripansi(%2)} _nodef MapFormatter;; #sub {%1 %cr %2};#if (@RoomDesc) {RoomDesc=%concat(@RoomDesc,@RoomDescLine)} {#var RoomDesc {%concat(@RoomDescLine,' ')} _nodef MapFormatter}} "" {notrig|color}
#TRIGGER {Now now, don't be so hasty!} {#NODIR;#ABORT} "" {notrig}
#TRIGGER {There is (*) in the way} {#DOOR %lastdir() %1;#NODIR;#ABORT} "" {notrig}
== Room Exits Trigger Line 1 ==> #TRIGGER {%e[1;34m(*)} {; Anything in this color will be searched for;; exits and all exits found will be added to;; the RoomExitList variable.;;;; #echo EXITS LINE;; #echo parsing first exits line;#if (! %maplocked() & ! @DescTagged) {#tag desc @RoomDesc;#var DescTagged {1} _nodef MapFormatter};#var RoomExitsRaw {%1} _nodef MapFormatter;#if (! %pos(".",@RoomExitsRaw)) {#echo Activating ExitsN;#T+ ExitsN};#var RoomExitsStripped { %stripansi(%replace(%replace(%replace(@RoomExitsRaw,",","")," ","|"),".",""))
} _nodef MapFormatter;;;#forall @DirectionsList {#if (%ismember(%i,@RoomExitsStripped)) {#additem RoomExitList %i}};#if ((! %maplocked) & (@RoomDetected) & %pos(".",@RoomExitsRaw)) {#echo Tagging exits;#var RoomExits {%replace(@RoomExitList,"|"," ")} _nodef MapFormatter;#tag exit @RoomExits;#unvar RoomDetected MapFormatter}} "" {notrig|color}
#TRIGGER {You are recovering equilibrium and cannot move yet.} {#NODIR;#ABORT} "" {notrig}
#TRIGGER {There's water ahead of you. You'll have to swim in that direction to make it} {#NODIR;#ABORT} "" {notrig}
#TRIGGER {There is no exit in that direction.} {#nodir;#ABORT} "" {notrig}
#REGEX "ExitsN" {(.*)} {#var RoomExitsRawN {%1} _nodef MapFormatter;#echo Nth exits line: @RoomExitsRawN;#var RoomExitsStrippedN { %stripansi(%replace(%replace(%replace(@RoomExitsRawN,",","")," ","|"),".",""))
} _nodef MapFormatter;;;#forall @DirectionsList {#if (%ismember(%i,@RoomExitsStrippedN)) {#echo %i: %ismember(%i,@RoomExitsStrippedN);#additem RoomExitList %i}};#if ((! %maplocked) & (@RoomDetected) & %pos(".",@RoomExitsRawN)) {#echo Tagging exits;#var RoomExits {%replace(@RoomExitList,"|"," ")} _nodef MapFormatter;#tag exit @RoomExits;#unvar RoomDetected MapFormatter};#T- ExitsN} "" {notrig}
#REGEX {(open door), southwest, and northwest.} {bounce}
#CLASS 0



2420h, 2330m cexdb-l
Fair Seas Lane approaching the marina. 
Fair Seas Lane splits here where it turns into Cliffside Road. The grand houses
lining either side of Cliffside to the north east add grandeur to the 
intersection, while the rocky beach barely visible to the south east adds a bit
of relaxed scenery. Tall sails of the many moored ships at the marina can be 
seen poking out from above the houses that line the street to the south, while 
on the northern side, nestled among the residences, a small, but tidy shop 
rests just a few inches back from the pavement. A wooden sign hangs above the 
door reading "Pjeter's Bait and Tackle". A rune resembling a horse has been 
sketched into the ground here. A runic totem is planted solidly in the ground. 
A sewer grate looms darkly beneath your feet. A sleek pony grazes nearby. A 
nebulous water weird is here.
You see exits leading north (open door), northeast, east (open door), 
Activating ExitsN
southeast, south (open door), southwest, and west (open door).
2420h, 2330m cexdb-Nth exits line: You see exits leading north (open door), northeast, east (open door),
2420h, 2330m cexdb-Nth exits line: You see exits leading north (open door), northeast, east (open door),
north: 5
east: 8
northeast: 7
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Sun Mar 07, 2004 7:36 pm   
 
I had to remove all your #ECHOs and comments. The #ECHOs cause problems when trying to do precision multiline captures and should be sent to another window when they are needed for debugging. I also rearranged the code considerably to reduce the amount of processing being done, in the process I think I eliminated the need for a few variables. Here you are:

#TRIGGER "ExitLineTrig" {%e[1;34m(*)} {#IF (! %maplocked() & ! @DescTagged) {#TAG desc @RoomDesc;#VARIABLE DescTagged {1} _nodef MapFormatter};#VARIABLE RoomExitsRaw {%stripansi("%1")} _nodef MapFormatter;#IF (%ends(@RoomExitsRaw,".")) {#STATE ExitLineTrig 2;#SET ExitLineTrig 2 1}} "" {notrig|color}
#COND {} {#VARIABLE RoomExitsRaw {%concat(@RoomExitsRaw,%line)} _nodef MapFormatter;#IF (%ends(@RoomExitsRaw,".")) {#STATE ExitLineTrig 2;#SET ExitLineTrig 2 1}} {looplines|param=3|color}
#COND {} {#VARIABLE RoomExitsStripped {%subchar(%replace(%subregex(@RoomExitsRaw,"(?:You see exits leading|and|(a+ door))",""),", ","|")," .","")} _nodef MapFormatter;#IF ((! %maplocked) & (@RoomDetected)) {#ECHO Tagging exits;#VARIABLE RoomExits {%replace(@RoomExitsStripped,"|"," ")} _nodef MapFormatter;#TAG exit @RoomExits;#UNVAR RoomDetected MapFormatter}} {manual|color}
Reply with quote
Spartacus
Wanderer


Joined: 23 Apr 2001
Posts: 53
Location: USA

PostPosted: Sun Mar 07, 2004 11:22 pm   
 
Thanks!

I did have to add "#STATE ExitLineTrig 0" right after the #TAG in state 2, but now it works perfectly!

And - since it works now, I killed all the #ECHOs :p

Spartacus
Reply with quote
Display posts from previous:   
Post new topic   Reply to topic     Home » Forums » zMUD 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