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
selth
Newbie


Joined: 03 Aug 2005
Posts: 5

PostPosted: Wed May 24, 2006 4:31 am   

Capturing Data to a string list
 
Okay, I've spent most of the day on and off trying to figure this out, and I'm sure its just something simple that I'm not doing but I'm just not seeing it.

To explain. For the game I play someone has created a proxy that contains a fairly full featured map of the game world. It allows for quick movement etc.

However, there are some things that require slower movement that I want to set up in a little floating window.


Sample of output below:

Underlined portion is custom prompt due to the proxy

<422/422h 374/374m 1817e 1599w <eb>> [Path calculated in: xxxxxx microseconds.]
[Path: ne, e, se, se, se, ne, ne, se, se, sw, s, ne, w, w, sw, sw, w, nw,
w, nw, n, w, w, nw, u, u, s, u, w, sw, s, sw, w, n, nw, d, d, d, d, sw, sw,
sw, s, sw, sw, s, sw, se, s, w.]
<422/422h 374/374m 1817e 1600w <eb>>



#CLASS {Caravan}
#VAR Caravanpath {}
#REGEX {<([0-9]+)/[0-9]+h} {#t- "cpath"} "" {nocr|prompt}
#TRIGGER "cpath" {^(*)$} {#additem Caravanpath %replace( "%1", ",", "|")} "" {notrig|disable}
#TRIGGER {Path~:} {#t+ "cpath"}
#CLASS 0

Now, the theory I went with on this was to do trigger it to start the cpath capturing trigger from the Path: and then go from there until it hits the first prompt after the output, which has disables the specific cpath trigger


However, when I use #show @Caravanpath, to check the output

(w| nw| n| w| w| nw| u| u| s| u| w| sw| s| sw| w| n| nw| d| d| d| d| sw| sw|)|(sw| s| sw| sw| s| sw| se| s| w.])

is what it shows stored in the variable Caravanpath.

Compared to
ne, e, se, se, se, ne, ne, se, se, sw, s, ne, w, w, sw, sw, w, nw,
w, nw, n, w, w, nw, u, u, s, u, w, sw, s, sw, w, n, nw, d, d, d, d, sw, sw,
sw, s, sw, sw, s, sw, se, s, w.]

So, first of all, any clue why its not capturing that first line? I'm sure its something simple.

Second, I wasn't exactly sure about the nested replace functions, since apparently, it was randomly adding ( where a new line started in the output and ) where it ended and the ] that it captured from the original output as well. Those I obviously want gone.

Once I get those two basic thigns figured out, I think I can do the rest of what I want to do on my own.

I appreciate the help!
Reply with quote
Larkin
Wizard


Joined: 25 Mar 2003
Posts: 1113
Location: USA

PostPosted: Wed May 24, 2006 2:22 pm   
 
Try using %concat to join the two lists instead of #additem to add your list to another list. What you end up with your way is a list of lists, since the %replace output will be a string list itself and #additem just adds the whole list to another string list.

Code:
#var list1 {item1|item2|item3}
#var list2 {item4|item5|item6}
#var list3 %concat(@list1, "|", @list2)


You may need to also add a line to delete blank elements if you have an empty string list being concatenated this way.
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed May 24, 2006 5:02 pm   
 
In an offline test situation I get the first line stored without a problem. The only difference I have when I do an export is the order of the triggers and a slight variation of the switch on trigger with an anchor and a notrig.
Code:
#CLASS {Caravan}
#VAR Caravanpath {}
#REGEX {<([0-9]+)/[0-9]+h} {#t- "cpath"} "" {nocr|prompt}
#TRIGGER {^~[Path~: } {#t+ "cpath"} "" {notrig}
#TRIGGER "cpath" {^(*)$} {#var Caravanpath %concat(@caravanpath,%replace("%1", ",", "|"))} "" {notrig|disable}
#CLASS 0
I tested the above with the following command line.
Code:
#show ""
#showprompt ~<422/422h 374/374m 1817e 1599w ~<eb~>~>
#show " ~[Path calculated in: xxxxxx microseconds.~]"
#show "~[Path: ne, e, se, se, se, ne, ne, se, se, sw, s, ne, w, w, sw, sw, w, nw~,"
#show "w, nw, n, w, w, nw, u, u, s, u, w, sw, s, sw, w, n, nw, d, d, d, d, sw, sw~,"
#show "sw, s, sw, sw, s, sw, se, s, w.~]"
#showprompt ~<422/422h 374/374m 1817e 1600w ~<eb~>~>
I get the following stored in the Caravanpath variable.
Code:
[Path: ne| e| se| se| se| ne| ne| se| se| sw| s| ne| w| w| sw| sw| w| nw|w| nw| n| w| w| nw| u| u| s| u| w| sw| s| sw| w| n| nw| d| d| d| d| sw| sw|sw| s| sw| sw| s| sw| se| s| w.]
Oh and of course I've used the concat method in place of the #additem as suggested by Larkin.
_________________
Taz :)

Last edited by Taz on Wed May 24, 2006 6:25 pm; edited 2 times in total
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed May 24, 2006 5:21 pm   
 
I just did an offline test with the trigger order the way you have it and get your results which lacks the first line of directions. Thinking back to a post by Zugg I guess this is because of the way triggers are put onto the execution stack and how they act with received lines.

In your version 1, 2 and 3 are put on the stack, 1 fires, 2 is ignored as it is disabled, 3 fires and turns on 2 but 2 is above 3 stack wise and has already been dealt with for this line.

In my version 1, 2 and 3 are put on the stack, 1 fires, 2 fires and turns on 3 which is now below 2 and hence fires for this line.

So there is your answer and over to you to tidy up that string list. Naaaasty! Razz

<edit>
It's not too bad, you only have to nest three more replaces, or two if you're not bothered about the spaces.
</edit>
_________________
Taz :)

Last edited by Taz on Wed May 24, 2006 6:20 pm; edited 1 time in total
Reply with quote
Taz
GURU


Joined: 28 Sep 2000
Posts: 1395
Location: United Kingdom

PostPosted: Wed May 24, 2006 6:15 pm   
 
Code:
#var Caravanpath %concat(@caravanpath,%replace(%replace(%replace(%replace("%1", ".]", ""), "[Path:" ,""), " ", ""), ",", "|"))

   line1: [Path: ne, e, se, se, se, ne, ne, se, se, sw, s, ne, w, w, sw, sw, w, nw,
      %1: [Path: ne, e, se, se, se, ne, ne, se, se, sw, s, ne, w, w, sw, sw, w, nw,
replace1: [Path: ne, e, se, se, se, ne, ne, se, se, sw, s, ne, w, w, sw, sw, w, nw,
replace2:  ne, e, se, se, se, ne, ne, se, se, sw, s, ne, w, w, sw, sw, w, nw,
replace3: ne,e,se,se,se,ne,ne,se,se,sw,s,ne,w,w,sw,sw,w,nw,
replace4: ne|e|se|se|se|ne|ne|se|se|sw|s|ne|w|w|sw|sw|w|nw|
  concat: ne|e|se|se|se|ne|ne|se|se|sw|s|ne|w|w|sw|sw|w|nw|

   line2: w, nw, n, w, w, nw, u, u, s, u, w, sw, s, sw, w, n, nw, d, d, d, d, sw, sw,
      %1: w, nw, n, w, w, nw, u, u, s, u, w, sw, s, sw, w, n, nw, d, d, d, d, sw, sw,
replace1: w, nw, n, w, w, nw, u, u, s, u, w, sw, s, sw, w, n, nw, d, d, d, d, sw, sw,
replace2: w, nw, n, w, w, nw, u, u, s, u, w, sw, s, sw, w, n, nw, d, d, d, d, sw, sw,
replace3: w,nw,n,w,w,nw,u,u,s,u,w,sw,s,sw,w,n,nw,d,d,d,d,sw,sw,
replace4: w|nw|n|w|w|nw|u|u|s|u|w|sw|s|sw|w|n|nw|d|d|d|d|sw|sw|
  concat: ne|e|se|se|se|ne|ne|se|se|sw|s|ne|w|w|sw|sw|w|nw|w|nw|n|w|w|nw|u|u|s|u|w|sw|s|sw|w|n|nw|d|d|d|d|sw|sw|

   line3: sw, s, sw, sw, s, sw, se, s, w.]
      %1: sw, s, sw, sw, s, sw, se, s, w.]
replace1: sw, s, sw, sw, s, sw, se, s, w
replace2: sw, s, sw, sw, s, sw, se, s, w
replace3: sw,s,sw,sw,s,sw,se,s,w
replace4: sw|s|sw|sw|s|sw|se|s|w
  concat: ne|e|se|se|se|ne|ne|se|se|sw|s|ne|w|w|sw|sw|w|nw|w|nw|n|w|w|nw|u|u|s|u|w|sw|s|sw|w|n|nw|d|d|d|d|sw|sw|sw|s|sw|sw|s|sw|se|s|w
Boy am I bored waiting for CMUD to come out.

*gives Zugg a cheer* -> "Go Zugg! Go!" Embarassed Laughing
_________________
Taz :)
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