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
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Wed Mar 25, 2009 10:03 pm   

need help with my trigger please.
 
Hi,

my mud outputs

#K%xxx011AAC1.6 days

xxx is just a bunch of random 5 digits, 011 is the number of characters that appear after it, AAC is also nothing important, it can change, but it is always 3 capital letters. what i want to capture is 1.6 days. however, it is possible for another output to have 099 instead of 011, then i will need to capture the 99 characters that come after the 099. so, i have this trigger

~#K~%@code&%d{length}&%w{tag}&%eval(@length-3)
and i capture the string i want with #VAR string %3

this only works sporadically.

Help please.
Oh, and is there anyway to force the pattern &%w{tag} to capture only 3 letters?

Thanks!
Reply with quote
Leitia
Adept


Joined: 04 May 2007
Posts: 292
Location: Boston

PostPosted: Thu Mar 26, 2009 2:44 am   
 
Code:
^~#K\d\d\d\d\d\d\d\d[A-Z][A-Z][A-Z](\d\.\d) days


worked for the days, I am not sure what you need though, regex trigger, examples of what that is would be better
Reply with quote
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Thu Mar 26, 2009 6:46 am   
 
basically, the 1.6 days i gave in the example, can be "A~1323~C~685~E~68~G~10~J~<rxxxxx: [2/2]> <vxxxxxxxx: [3/3]> Reset: [30%] xxxx: xxxxxxxxxx" or "Main Trader (s)" or even just "C~799"
1 big problem with the output is that it doesn't come with a carriage return, so it can be strung together like

#K%xxxxx011AAC1.6 days#K%xxxxx069FFFJ~<rttttt: [2/2]> <vtttttttt: [3/3]> Reset: [50%] tttt: tttttttttt#K%xxxxx019FFFA~1329~C~692~G~8#K%xxxxx008FFFC~765#K%xxxxx011AAC1.8 days

so, my idea is to capture the 3 digits which show how many characters that certain output contains, so that i know how many characters to capture each time. hmmm, does that make sense?
thanks for helping, i've been stumped for days...
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Mar 26, 2009 2:55 pm   
 
There is no way to have the trigger know while processing the trigger how many characters to capture. The only way is to capture everything after the AAC (or other three letters) and slice off the right number of characters within the trigger value. So, something like this:
Code:

<trigger priority="320" id="32">
  <pattern>~#K~%&amp;5(&amp;3)(&amp;3)(*)</pattern>
  <value>#local $length $code $data
$length = %int(%1)
$code = %2
$data = %left(%3, $length)</value>
</trigger>

Caveat: I have not actually used the &nn pattern before, but according to my reading of the documentation, that pattern should work.
Reply with quote
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Fri Mar 27, 2009 7:56 pm   
 
hmm, problem with that is that is that the output strings together one after the other so i'll only end up catching the first one. is there anyway to tell the trigger to like, match everything UNTIL it reaches #K?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Mar 27, 2009 8:32 pm   
 
is this a prompt line? Perhaps an easier method would be to make this trigger an "on prompt" trigger, and also have it insert a carriage return. Then the next prompt will be on it's own line, and the trigger will fire again.
Reply with quote
oldguy2
Wizard


Joined: 17 Jun 2006
Posts: 1201

PostPosted: Mon Mar 30, 2009 5:53 pm   
 
Actually it isn't a prompt line but I just found a link over in the Beta forum showing that line.

http://www.gameaxle.com/PortalMIP9.pdf
Reply with quote
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Mon Mar 30, 2009 7:25 pm   
 
yeah, that's what got me started.
any ideas?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Mar 31, 2009 3:41 pm   
 
The best idea that comes to mind is to automatically insert a carriage return before every #K% pattern, or at the end of the line. Something like this might work:
Code:

<trigger priority="1" trigontrig="false" newline="false" prompt="true" id="32">
  <pattern>~#K~%</pattern>
  <value>#show %crlf</value>
</trigger>

It is priority 1 so that it will happen before any other triggers. It is set to trigger on prompt, so it will happen as soon as that pseudo-prompt text appears, not waiting for a newline. That way your other triggers should be able to work on each one of these #K% patterns separately, without having to worry about more than one appearing on a line.
Reply with quote
cazador
Apprentice


Joined: 08 Dec 2005
Posts: 108

PostPosted: Tue Mar 31, 2009 6:34 pm   
 
After playing with this. I was able to do a little better job splitting the stuff up with the following code:


Code:

<trigger priority="1" regex="true" prompt="true" id="91">
  <pattern>(.*)(#K.*)(#K.*)</pattern>
  <value>#if (%1 !="")
{
#show %1
}
#show %2
#show %3</value>
</trigger>
Reply with quote
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Tue Mar 31, 2009 7:45 pm   
 
ok wow, that worked great. except for 1 thing. thanks alot Rahab.

#K%47180011AAC4.2 days#K%47180011AAF1.8 days

always seems to come out at the same time, so it doesn't work as planned. instead, i get 2 newlines after that appears.
i tried:
Code:
<trigger priority="1" id="6779">
  <pattern>~#K~%(*)#K~%(*)</pattern>
  <value>#SHOW #K~%%1
#SHOW #K~%%2</value>
</trigger>

but it doesn't work. more help would be much appreciated!

also, is there anyway to capture a specific number of letters into a variable i know you can use &%d{varname}, but how do you capture exactly 3 letters into the variable?

there is this output
#K%47180069FFFJ
i want to capture the first 5 numbers, the next 3 numbers, FFF and J into 4 separate variables.


thanks much in advance.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Tue Mar 31, 2009 8:56 pm   
 
Sav, did you try my text exactly as I had it? The prompt="true" part is important. If you did, then perhaps the mud is actually putting both of those on at the same time, instead of at separate times as I thought.

I showed you how to capture an exact number of characters before. The pattern you need is &nn, where nn is the number of characters. In the XML I did early in this discussion, the ampersand is translated into "&amp;"
Reply with quote
cazador
Apprentice


Joined: 08 Dec 2005
Posts: 108

PostPosted: Tue Mar 31, 2009 9:08 pm   
 
Code:

<trigger priority="930" regex="true" id="2">
  <pattern>^#K%\d{5}($count:\d{3})($literal:\w{3})($data:.*)</pattern>
  <value>#gagspace
#sh %delete($data,1,$count)
$data=%delete($data,$count,99999)
@process_mips($literal,$data)
</value>
  <arglist>$count,$literal,$data</arglist>
</trigger>
Reply with quote
sav
Wanderer


Joined: 09 Jan 2006
Posts: 86

PostPosted: Tue Mar 31, 2009 11:04 pm   
 
rahab: yup, i put it in exactly as you had it. it works perfectly, except for that instance. i'm pretty sure the mud sends it to me at exactly the same time. so i'm not sure how to split it if so.

rahab & cazador: thanks guys!

now that i've managed to capture the info i need correctly, i'll probably need help with extracting the data from the variables. i'll try it out on my own first though. thanks alot!
Reply with quote
cazador
Apprentice


Joined: 08 Dec 2005
Posts: 108

PostPosted: Wed Apr 01, 2009 12:08 am   
 
sav: I am also working on doing this, if you want you can pm me and we can figure out a way to colaborate more
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