|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Sun Dec 17, 2006 6:31 am
Mutltiple line pattern matching |
In my mud, I can identify an object by castt an identify spell. When I do this, I would like to capture the complete identify text to a file. So for the mud output below, I'd like to capture everything between the =-=-=-=-= lines, including those lines, and put it in a text file. So far I've been able to do this by using the #lo command and a series of triggers. Right now, I have an open trigger to open on the first =-=-= a midline trigger that triggers on ---- and a close trigger that triggers on 1145/1145. I have an alias that arms the opening trigger, then I cast the spell which opens a #log file, when the =-=-=- comes up, it arms the midline trigger and disarms the open trigger. when the --- comes up it arms the close trigger and disarms the midline trigger when the 1145/1145 comes up, it closes the log and disarms the close trigger
Quote: |
1145/1145H 521/525M 211/211V 3RV 140156720XP -11.5AC 137gp 3am
cast 'identify' medal
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
A fuchsia medal would be considered a piece of treasure.
-------------------------------------------------------------------------------
It can be worn on your torso.
It has a weight of 5 and a value of 500 gold pieces.
You need to be level 41 to use it.
-------------------------------------------------------------------------------
Its special properties will improve your armor class by -3.0
It will increase your strength by 2.
It will increase your constitution by 1.
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
1145/1145H 505/525M 211/211V 3RV 140156720XP -11.5AC 137gp 4am
|
The problems I have is that sometimes I get a blank line ahead of the first =-=-=- in the log file, and sometimes there is mud output between the second =-=-=- and 1145/1145. I've tried to trigger #lo on the second =-=-= but it then cuts off the =-=-=- ...
I would like to try to get away from the #lo usage, but I cant figure out how to use #write (or other command) to capture all of the text between these two lines. Any help out there?
Edit:I just tried a multistate trigger. I set up a new trigger with the pattern being the ful =-=-=- line and this as the script:
Code: |
#LO newidtemp.txt
#COND {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} {#lo;#t- newidopen} |
I thought This might work, but it doesn't close the log file. |
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Sun Dec 17, 2006 7:33 am |
#TR {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} {#LOG identify.txt;#FILE 1 identify.txt}
#COND {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= } {#LOG;#WRITE 1 {%line}} |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Sun Dec 17, 2006 7:49 am |
I tried your code and other variations, and it doesn't look like the conditional part is firing. and it actually fires the main trigger again on the second =-=-=- line. I also tried to add {skip|param=4} after the conditional trigger script, but that didnt help either.
|
|
|
|
Caled Sorcerer
Joined: 21 Oct 2000 Posts: 821 Location: Australia
|
Posted: Sun Dec 17, 2006 8:27 am |
Yeah, I'm having a bit of trouble with it myself. I can get it to log on and off, but I can't get it to capture the final line of =-=-=-=-=.
#TR {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} {#LOG identify.txt}
#COND {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= } {}
#COND {*} {#LOG}
You'd think that'd work, but nope - the final line still doesn't capture. Oh.. try deleting the trig and starting again. For some reason I had lots of trouble until I did that. |
|
_________________ Athlon 64 3200+
Win XP Pro x64 |
|
|
|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Sun Dec 17, 2006 4:08 pm |
when I try the code you've suggested, the trigger itself fires twice rather than having the trigger fire, then the condition. I tried this with a brand new trigger on a room description in my mud, I made it as simple as I could think of just to test and see how/if conditions worked. The #condition just wont fire... I'm beginning to think this is a bug.
|
|
|
|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Sun Dec 17, 2006 7:19 pm |
Well, I finally kinda got it to work. I first have to say that I couldnt get #cond to work. I had to go into the main trigger in the settings editor and create a new trigger state, then enter the info into that. I'm not sure why #cond didnt work to set up a new trigger state.
So when I got it to work, I set up a main trigger to fire on the first bar )=-=-=) and a second state to fire on the second bar. Ultimately I couldn't get the last =-=- bar to capture into the log, so I did as you suggested, and re-opened the file and wrote the second bar on the end of it.
I think what I've been doing wrong is I've been placing the #cond command inside of a trigger, so each time the trigger fired, it would create a new condition somewhere in my setting. Turns out i had one trigger that had 72 conditions created, I think because every time id try to run the trigger it would create a new state, rather than firing the #cond trigger that I was stipulating. This was a big one, this has always confused me, the difference between script like caled uses in this thread and creating the same script by using the gui. Sorry for the ramblings, and in maybe a few more years i'll know how to use cmud!!! |
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Thu Dec 21, 2006 2:17 am |
I'm not sure what the problem is here. I created an alias to echo your example output for testing, then ran this from the command line:
#trig {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} {#echo test1};#cond {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=} {#echo test2}
and it worked just fine. Also worked if I sent the two commands separately (not on different lines of the same command line, or with a semicolon). |
|
|
|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Thu Dec 21, 2006 1:48 pm |
I have it working now, using a trigger and 1 trigger state just like you show fang, however using the the #log command to open and close a log to collect all the info in between the =-=-=-=- lines, I have to #write the closing=-=-=- into the file because the closing trigger stops the log before the closing bar is logged. This is the code I have for the closing bar trigger
Code: |
#t- idsecondbar
#t- idfirstbar
#cw blue,high
#lo
#file 2 tempitemid.txt
#write 2 {=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=}
#close 2
#t- idsecondbar
#t- idfirstbar
#t- Appendgag
#t- appendgag2 |
I'm not quite sure why I have redundant trigger switches for the idbars. I'd like to find a way to trigger the log to close after the bottom idbar has been captured. I've played around with the trig on newlin, and trig on prompt check boxes for the closing idbar state, without any success. |
|
|
|
Arminas Wizard
Joined: 11 Jul 2002 Posts: 1265 Location: USA
|
Posted: Thu Dec 21, 2006 3:20 pm |
Why not match a new line at the end of the trigger condition that closes the log?
Trigger pattern
Blah blah
Trigger command
Start log
Trigger pattern
End blah blah$*
Stop log?? |
|
_________________ Arminas, The Invisible horseman
Windows 7 Pro 32 bit
AMD 64 X2 2.51 Dual Core, 2 GB of Ram |
|
|
|
jed Adept
Joined: 18 Dec 2005 Posts: 246
|
Posted: Thu Dec 21, 2006 6:29 pm |
I think what ur saying is to trigger the close on the next line I see after the closing =-=-=-=-=- bar. The problem there, is that sometimes the next line might be blank, and sometimes it may have text in it. However it works, Im thinking it's got to trigger of the closing bar... Thanks for the reply
|
|
|
|
Fang Xianfu GURU
Joined: 26 Jan 2004 Posts: 5155 Location: United Kingdom
|
Posted: Fri Dec 22, 2006 6:51 pm |
Try adding a third condition to the trigger with the pattern *. Should fire even on a blank line (test it first), and you can use that to turn off the log.
|
|
|
|
|
|