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
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Fri Aug 24, 2007 7:19 pm   

Multiline Channel Capture
 
Ok, I am trying to get it so #cap will grab multiline tells etc with no success.

here is the code I am using, anything I am doing wrong?

Code:

Trigger:  You tell (*), ~"

Syntax: 
#CAP -1 Chat
#gag
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Fri Aug 24, 2007 7:41 pm   
 
In order to capture multiline tells you need to have something that is understandable as an ending condition. A prompt, blank line, or specific character will do. I chose to use a quote character since the miniscule information you provided made it seem a likely choice. Then you end up with a trigger like this:

#TRIGGER "TellCap" {^%w tell{s|} %w, "} {#CAP Chat;#GAG;#IF (%ends(%line,%char(34))) {#STATE TellCap 2}}
#COND {} {#CAP Chat;#GAG;#IF (%ends(%line,%char(34))) {#STATE TellCap 2}} {looplines|param=10}
#COND {*} {#NOOP Wait state to reset the trigger} {wait|param=10}
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Fri Aug 24, 2007 8:05 pm   
 
Is it possible to just have it capture X number of lines?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Aug 24, 2007 8:40 pm   
 
It's possible using #c+ and #c- by counting the number of lines, but it's difficult since the you won't know in advance how many lines any given tell is going to run onto. This is one of the most frequently-asked about problems, but is also quite complex.

I normally offer two solutions.

1) Turn off server-side word wrapping. Not all MUDs let you do this - personally, I refuse to play on MUDs that don't let you set your own wrap length for exactly this reason. If yours does, turn off server-side word wrapping and then a simple

#trig {You tell, "(*)"} {}

will work fine. If you want to, you can set up CMUD's word wrapping to imitate the old server-side wrapping without breaking this kind of trigger as "hard" wrapping does.

2) Some sort of trigger. My solution is slightly different to Viji's and normally looks something like this:

Lines look like You tell Toihva, "I am the monkey - I can go anywhere!" where tells always end in ". You can use this to set up your trigger:

#trig "TellCap" {You tell %w, "} {#cap chat;#gag;#if %ends(%line,~") {#state TellCap 0;#t+ captrig}}
#cond {~"$} {#t- captrig}

#trig "CapTrig" {^*$} {#cap chat} "" {disable}

You might need to adjust the priority value of CapTrig to make this work - you might find it working best with a priority value between or less than those of TellCap and its condition.

As you can see, the basic approach to the problem is the same - Detect a line that starts a tell, and then check if that line also ends the tell. If it does, don't do anything special, just capture it. If it doesn't end the tell, start capturing everything until you receive a marker that ends the tell.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)

Last edited by Fang Xianfu on Sat Aug 25, 2007 4:29 am; edited 1 time in total
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Fri Aug 24, 2007 8:45 pm   
 
ok, will try that out in a couple. Thanks for the help Fang and Viji.
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Fri Aug 24, 2007 10:21 pm   
 
so basically the way the #capture in the CMud tutorial etc isn't fully enabled finished? When I first started to try and use it, they said using a -1 would display all lines in the capture.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Fri Aug 24, 2007 10:27 pm   
 
#cap -1 Chat is working as intended - it copies the entire buffer from one window to another. That isn't what you want in this case, though - you just want to capture the text that's part of a tell and hence the more complex solution.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Fri Aug 24, 2007 10:39 pm   
 
Ahhh. ok. Thanks.
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Sat Aug 25, 2007 4:24 am   
 
Fang Xianfu wrote:
It's possible using #c+ and #c- by counting the number of lines, but it's difficult since the you won't know in advance how many lines any given tell is going to run onto. This is one of the most frequently-asked about problems, but is also quite complex.

I normally offer two solutions.

1) Turn off server-side word wrapping. Not all MUDs let you do this - personally, I refuse to play on MUDs that don't let you set your own wrap length for exactly this reason. If yours does, turn off server-side word wrapping and then a simple

#trig {You tell, "(*)"} {}

will work fine. If you want to, you can set up CMUD's word wrapping to imitate the old server-side wrapping without breaking this kind of trigger as "hard" wrapping does.

2) Some sort of trigger. My solution is slightly different to Viji's and normally looks something like this:

Lines look like You tell Toihva, "I am the monkey - I can go anywhere!" where tells always end in ". You can use this to set up your trigger:

#trig "TellCap" {You tell %w, "} {#cap chat;#gag;#if %ends(%line,~") {#state TellCap 0};#t+ captrig}
#cond {~"$} {#t- captrig}

#trig "CapTrig" {^*$} {#cap chat} "" {disable}

You might need to adjust the priority value of CapTrig to make this work - you might find it working best with a priority value between or less than those of TellCap and its condition.

As you can see, the basic approach to the problem is the same - Detect a line that starts a tell, and then check if that line also ends the tell. If it does, don't do anything special, just capture it. If it doesn't end the tell, start capturing everything until you receive a marker that ends the tell.


Would I just cut and paste that in, or do I need to doctor the code up some?

Also, which one should be enabled to begin with. It is now capturing everything into the chat window.


Last edited by Toihva on Sat Aug 25, 2007 4:31 am; edited 1 time in total
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Aug 25, 2007 4:30 am   
 
It depends on exactly what your lines look like - if they're different from the example I gave, you'll need to change the pattern. If you can give us some examples of lines, we can help with that.

I also just noticed that I'd put a brace in the wrong place - it's fixed now.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Sat Aug 25, 2007 4:34 am   
 
examples of some of the stuff I wish to capture...


(Snowdrifter): You say, "Ok, testing this thing."

(Ithaqua): Malphaeus says, "Is the meat at the junction for anyone?"

as well as


tells you, in Lycaean, "How does this sound: This male gyrfalcon has
pearly white plumage, each back feather tipped in black, giving him an almost
scaled."

I am also using the second example you gave me.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Aug 25, 2007 4:43 am   
 
Ah, Imperian. How I wish it had the CONFIG SCREENWIDTH option like Achaea and Lusternia :(

Perhaps a regex instead of a Zugg pattern?

^(?:\(\w+): \w+ says?|You tell \w+|\w+ tells you(?:,in \w+)?), \"

Or something similar. You could accomplish much the same thing if you created more than one trigger - just give them different IDs and change the ID that the #state command uses. One for channels, one (or two) for tells.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Sat Aug 25, 2007 4:45 am   
 
I did. But how would I config it up so it just captures the tells and channels.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Aug 25, 2007 4:49 am   
 
You can use one trigger with a (non-regex) pattern like ^~(%w~) %w says, ~" to get your channels, and then two triggers ^You tell %w, ~" and ^%w tells you, ~". The regex above just incorporates them all into one pattern, since the actual script for each one is the same.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Sat Aug 25, 2007 4:53 am   
 
ahhh, and which type of arguements should I work on for the 'guts' of the trigger?
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Sat Aug 25, 2007 4:58 am   
 
You should actually be able to plug these patterns straight into the example I gave you. The only thing you'll have to change is the IDs of the triggers so they're unique, and then change the #state command to match the name of the trigger that it's inside.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Sat Aug 25, 2007 5:02 am   
 
I did that, now it wont capture to the channel. Its strange. I just did a cut and paste of the code. I even got it to work on Reg expression you gave me.
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Mon Aug 27, 2007 4:09 am   
 
Ok, now nothing is working.

Using the regex code and it doesn't even fire at all.

It will capture some lines then out of the blue nothing

Sometimes it will capture everything.
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Mon Aug 27, 2007 6:29 pm   
 
As far as Regular Expressions go, I just need it to capture things such as


You tell Nespes Val'Sidos, "Aye."

Nespes tells you, "Ah, I see."

(Stavenn): Onyn says, "Sounds like fun."
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 6:59 pm   
 
You don't actually need to use regexes for those, really. It's just that you can't use wildcards inside CMUD's own {one|two|three} syntax, so I needed to use a regex to combine them all. You could easily make three triggers:

#trig {^You tell [a-zA-Z ], "} {}
#trig {^%w tells you, "} {}
#trig {^~(%w~): %w says, "} {}

EDIT: Perhaps that last one should be ^~(%w~): %w say{s|}, " instead to capture you talking as well?
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Mon Aug 27, 2007 7:52 pm   
 
Now is the part that is going to be the pain, the internals. Even with the examples and hints given, the only thing my triggers will do is either capture everything OR nothing.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 8:02 pm   
 
What does your code look like? In what circumstances does it match, and when does it fail?

Take a look at the examples above. These examples are both designed to check if the line is ending the tell as well as beginning it (with the use of %ends), and if it doesn't, capturing extra lines until the line that ends the tell is reached. Your script will need to do something similar.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Mon Aug 27, 2007 10:18 pm   
 
Thats the thing, I used the above examples and no capture. For some reason it will either capture nothing or everything. As far as the code, it is what was given.
Reply with quote
Fang Xianfu
GURU


Joined: 26 Jan 2004
Posts: 5155
Location: United Kingdom

PostPosted: Mon Aug 27, 2007 11:04 pm   
 
You say sometimes - you mean sometimes it works and sometimes it doesn't on exactly the same text, or that some text causes it to fail and other text succeeds? If the latter, give us an example of each.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Toihva
Novice


Joined: 20 Nov 2004
Posts: 38

PostPosted: Tue Aug 28, 2007 1:20 am   
 
One time it will not capture anything.

the next I can get soemthing like

Road at the edge of the valley. (road).
A smattering of clouds fills the sky, lacing it with spiderwebs of grey. After
a long journey you find yourself at the very edge of the Modin Valley, the
Ravana Hills receding into the distance gradually declining in their mass and
height, merging with the green-clad floor of the valley. The road continues to
swathe through the land, laying a path southerly, while rolling hills rise and
fall to the east, their veneral tip ringed with pine forests. An iridescent
moonstone lies here on the ground. A fierce sabretooth tiger prowls silently
here. Carefully watching everything, a white snow tiger slowly paces the area.
Lenos, Seeker of the Sanguine is here. She is holding a
tower shield in her left hand.
You see exits leading east, southeast, south, and northwest.
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