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


Joined: 07 Nov 2000
Posts: 53
Location: Germany

PostPosted: Tue Aug 21, 2007 10:38 pm   

Trigger one character in a line
 
Hi there!

Long enough away from mudding, now back, and also new problems in triggering, i hope you can help me out.

I want to capture multiple lines, and from the help of the finished Script section i have a solution.
But the first line is not always triggered.

What I want to do is capture channel tells and color them, every channel in another color,
let me give you some examples of some channel tells:

1) [Public:Dreamer] Hello there!
2) [Public:Dreamer says Hello]
3) [Murder:Ghost of a rat] Dreamer has killed me.

In Case 2) this is a comment who always ends with "]", if it goes more than 1 line, i use a condition to trigger and all goes well.

The problem I encounter is I can't say when the line ends and how to capture the "]" character in a line.
There doesn't follow a prompt to catch and to say the line has ended.
The lines sometimes don't end with a punctuation, so there is no way to say when it ends.
The only thing I know is: the channel tells start always with a "[" and somewhere in the middle or the end of the sentense there follows the closing "]".

If I have a trigger like ~[Public:* it would color it, but I have to see if there is a "]" in the line,
when there is no one in the first line, then it is always a comment that goes more than one line,
then my condition can trigger the ending "]".

I played with %ends and %begins, but that is not what i want, i want to have a pattern that sees if
there is the "]" in the first line, if not, then it has to fire my condition. Like: (%contains "]", then do this...)

Is there a command or function I am not seeing in my helpfile?
Hope there is someone out there who knows what I want to say and can help me out here on this one.


Using zmud 7.21 for now.
Thanks in advance for your help, if you need more examples then i can give more, but i hope i clarified all well.

Hugs,
Dreamer
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Tue Aug 21, 2007 11:01 pm   
 
Use a multistate trigger.

#trig {~[Public:} {...}
#cond {~]} {...} {within|param=10}

This will fire the condition only if the closing bracket is within 10 lines of the opening bracket. You need to be careful using this - it won't handle lines with the closing bracket on the same line as the opening bracket properly. But this will work for lines where they're different, and you can use something like #if %pos("]",%line) {#state 0} to reset the trigger in that case.

A much easier solution if your MUD lets you set the line length is to turn off server-side word wrapping. You can set up zMUD's word wrapping to mimic the MUD's if you find it easier to read, but with it on it'll let you do something like ~[Public:[%w ]~] or (regex) [Public:[\w ]+].
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Dreamer
Wanderer


Joined: 07 Nov 2000
Posts: 53
Location: Germany

PostPosted: Wed Aug 22, 2007 8:35 am   
 
Thanks for your answer Fang Xianfu.

What I had until now was something like:

Code:
#trig {~[public:(%x)(%x)%x)(*)} {#if (%ends( "%1", "]") OR %ends( "%2", "]") OR %ends( "%3", "]") OR %ends( "%4", "]")) {#STATE public 0} {#STATE public 1}}
#cond {(*)} {#IF (%ends( "%1", "]")) {#CO seagreen;#STATE public 0} {#CO seagreen;#STATE public 1}}


The problem with this is that sometimes I can't catch the closing bracket, if there are more than 4 words in the first line, or if less than 2 words, the trigger won't catch anything.

For your posted questions:
The MUD doens't allow to turn off server-side word-wrapping. :(

Quote:
- it won't handle lines with the closing bracket on the same line as the opening bracket properly.


But that's what I am trying to do, isn't there any possibility to do that in a good and simple manner? Perhaps in a regex manner? Sad

Now, going to work until tonight, I'll let my one character in the mud idle,
trying this: #if %pos("]",%line) instead of the %ends - functions to see if it works like I expect it to work.

I'll come later and tell if we got this to work.
Thanks for your time in seeing and writing back to this post.

Hugs,
Dreamer
Reply with quote
Vijilante
SubAdmin


Joined: 18 Nov 2001
Posts: 5182

PostPosted: Wed Aug 22, 2007 9:30 am   
 
The only idea I can come up with is a regex that allows the closing bracket to either be there or not. Then when the closing brack is not at the end of the line check its length. You might have to adjust the length comparison for your wrapping width, just remember to allow some for slightly larger words. The worst that happens with this method is that it colors 1 extra line.
Code:
#REGEX "Public" {^\[Public:.*?\]?} {#COLOR seagreen;#IF (%ends(%line,"]") OR (%len(%line)<70)) {#STATE Public 2}}
#COND {} {#CO seagreen;#IF (%ends(%line,"]") OR (%len(%line)<70)) {#STATE Public 2}} {looplines|param=30}
#COND {} {#NOOP Extra reset state} {wait|param=10}


This script is totally untested.
_________________
The only good questions are the ones we have never answered before.
Search the Forums
Reply with quote
Fang Xianfu
GURU


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

PostPosted: Wed Aug 22, 2007 11:08 am   
 
You might also want to change %ends to %pos in that script since some of your examples have the closing square bracket in the middle of a line.
_________________
Rorso's syntax colouriser.

- Happy bunny is happy! (1/25)
Reply with quote
Dreamer
Wanderer


Joined: 07 Nov 2000
Posts: 53
Location: Germany

PostPosted: Wed Aug 22, 2007 8:41 pm   
 
Hi!

Back again from work and just looked inte the MUD where my character was the last hours and all went well.
Everything colored well and stopped at last when the closing bracket came up (if it was in the first line or a multi-line tell). Very Happy

This is what I have so far:

Code:
#TRIGGER "public" {~[public:*} {#co seagreen;#if %pos("]",%line) {#STATE public 0} {#STATE public 1}} "Colors"
#COND {(*)} {{#IF (%ends( "%1", "]")) {#CO seagreen;#STATE public 0} {#CO seagreen;#STATE public 1}} {manual}

That's doing the trick for me now. What I can't say yet, is how it will behave with more time passing by, or if some strange
case happens that I didn't think of.
I will look into it further more and also the Regex Vijilante wrote, perhaps it isn't bad having one more condition...

Ant the %pos and %line thing, isn't bad at all, found it now in the "Predefined Variables" in zMUD Help, why didn't I
find it earlier? Will read a bit more about them.
Perhaps I should change my condition trigger a bit with %pos and %line to make it not
catch just "*", what would you suggest to do?

Ok, I can't say it's solved, but for now it works. If something wierd happens the next days, especially when creating
more triggers like that for other channel-tells, I'll come back and drop a line.

Thanks a lot for helping me out here for now Fang Xianfu and Vijilante!

Dreamer
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