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
ganmo
Beginner


Joined: 23 Oct 2008
Posts: 18

PostPosted: Thu Oct 21, 2010 8:55 am   

capture multiline chat doesn't work
 
I've been experimenting with capturing multiline text with cmud.
And didn't have any good result. Well first I thought it worked but it would only capture the first 2 lines.
So if the chat is longer than two lines it will not be capture everything. So wonder how to fix it?

Here's my script
Code:
#TRIGGER {^(~[Simyarin~])%s%x} {
#CAP chat
#GAG
}
#COND {^(%s)%x} {
#IF (%len( %1)>1)
{ #CAP chat;
  #STATE 1;
  #gag
}}


And here's a sample text I'm trying to capture
Code:
[Simyarin] player: hey guys. i know im asking a lot and stuff n shit.. but
           anyway, know any good eq for sims. im not asking for directions,
           just the names. cant think. i got filigree ring and thats good i
           think
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Thu Oct 21, 2010 12:32 pm   
 
I think you need to specify the id in the #STATE command. Give your trigger an id, and use that ID as the first argument of #STATE.
Reply with quote
Tech
GURU


Joined: 18 Oct 2000
Posts: 2733
Location: Atlanta, USA

PostPosted: Thu Oct 21, 2010 2:42 pm   
 
I would also recommend looking into using the Loop Lines or the Loop Pattern Trigger Types.

[Edit] i just tried pasting this code into CMUD command line and there was an error that prevent the second trigger state from compiling. That is a CMUD bug and I will post that separately, but after the quick fix, every thing worked fine. At least with the sample text you gave.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="10" copy="yes">
    <pattern>^(~[Simyarin~])%s%x</pattern>
    <value>#CAP chat
#GAG</value>
    <trigger>
      <pattern>^(%s)%x</pattern>
      <value>#IF (%len( %1)>1) { #CAP chat;
  #STATE 1;
  #gag
}</value>
    </trigger>
  </trigger>
</cmud>
_________________
Asati di tempari!

Last edited by Tech on Thu Oct 21, 2010 2:51 pm; edited 2 times in total
Reply with quote
ganmo
Beginner


Joined: 23 Oct 2008
Posts: 18

PostPosted: Thu Oct 21, 2010 2:45 pm   
 
I don't know how to add a ID synax for my above trigger,
but when I went in to the package manager and added ID manually in the trigger and changed the #STATE to #STATE(id_sim). I tried the trigger after that and got error, any idea?
Reply with quote
ganmo
Beginner


Joined: 23 Oct 2008
Posts: 18

PostPosted: Thu Oct 21, 2010 9:05 pm   
 
I tried another approach this time using the match pattern trigger loop

Code:
<trigger priority="460" id="46">
  <pattern>^(~[Simyarin~])%y</pattern>
  <value>#CAPTURE chat %line //saves capture to %line
#GAG</value>
  <trigger type="Loop Pattern">
    <pattern>^           %y</pattern>
    <value>#CAPTURE chat
#GAG</value>
  </trigger>
</trigger>


However in the pattern
Code:
<pattern>^           %y</pattern>

Can I specify that I want to match 11 whitespaces?
Reply with quote
Taz
GURU


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

PostPosted: Thu Oct 21, 2010 10:06 pm   
 
Pattern Matching wrote:
&nn matches exactly nn characters (fixed width pattern)

_________________
Taz :)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Fri Oct 22, 2010 12:05 am   
 
You can do what Taz suggests, but if you want to match a specific number of a specific type of wildcard you will need to use Regex or possibly the %repeat() function (assuming it works in a pattern, it'd be something like %%repeat(" ",11)).

It actually would be pretty swell if Zugg added the full &varname syntax style to &nn so that we could refine nn by the wildcard used (ie, &%d8 would match a fixed-width pattern of 8 numbers instead of continuing on with digits 9 through 13 AND without trying to capture the results to the @8 variable), but I think he previously shot that down as something that can't be translated into regex. At any rate, if %repeat() works in a trigger pattern then it's a moot point.
_________________
EDIT: I didn't like my old signature
Reply with quote
ganmo
Beginner


Joined: 23 Oct 2008
Posts: 18

PostPosted: Fri Oct 22, 2010 9:14 am   
 
I couldn't find any help about &nn, how am I supposed to use that?

didn't work using this, %%repeat(" ",11)),
assuming that you're supposed to but it in the pattern field

EDIT
seems to work now, I just had to remove one %, so it looks like this %repeat(" ",11))
but I still want to know how &nn is used. Any example?

I also wonder if I can add another case to this pattern so it will look for "[Simyarin]" and "> [Simyarin]"
Code:
<pattern> ^~[Simyarin~]* </pattern>
Reply with quote
Taz
GURU


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

PostPosted: Fri Oct 22, 2010 9:53 am   
 
Well &nn you just replace nn with the number of characters you want to match so in this case it would be:

^&11%y

but of course that will still match normal lines that begin with words so is actually no use here. Like Matt said if it could have taken an argument of space that would be cool.

Matt has it spot on though

^%%repeat(" ",11)%x

as the pattern works great.
_________________
Taz :)
Reply with quote
Taz
GURU


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

PostPosted: Fri Oct 22, 2010 9:55 am   
 
Your extra end round bracket is the problem, it seems that one % does work but I'm certain the correct method is to double up the %.

Use the pattern above and you'll be fine.

Ignore the &nn in this case it isn't any use.
_________________
Taz :)
Reply with quote
ganmo
Beginner


Joined: 23 Oct 2008
Posts: 18

PostPosted: Fri Oct 22, 2010 3:03 pm   
 
ah, didn't notice the extra bracket there.

Anyway I notice now that the trigger still doesn't work 100%
It will capture the chat lines I want, but sometimes it won't.

However if I do chat review of the last chat lines the trigger will then capture it.
So it seems that trigger works somewhat anyway.

Could this be a problem/bug with CMUD?
Reply with quote
Taz
GURU


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

PostPosted: Sat Oct 23, 2010 8:08 pm   
 
Did you definitely use %x as I found %y problematic? Perhaps even miss those out so you only ever match 11 spaces at the start of a line.
_________________
Taz :)
Reply with quote
ganmo
Beginner


Joined: 23 Oct 2008
Posts: 18

PostPosted: Sun Oct 24, 2010 11:00 pm   
 
yes I used %x, tried both actually and without also. All produced the fault. Dunno if it's because of the trigger or maybe the buffer vary?
Reply with quote
Taz
GURU


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

PostPosted: Mon Oct 25, 2010 12:10 pm   
 
Trigger Types wrote:
*Loop Lines
The parameter will be shown to sets the number of lines to test this trigger. The trigger will be tested each time a line is received from the MUD until the specified number of lines have arrived. The state will change when the specified number is reached, regardless of the number of times the trigger has matched in that time.
*Loop Pattern
Similar to loop lines. The parameter sets the number of times to match this pattern. The state will only change once the pattern has successfully matched that number of times, unlike looplines, which will move on once the number of lines has been received, regardless of the number of matches.

I suspect the state doesn't get set back to 0 when you are expecting it to. At some point it does but by that time the first line will have passed so the trigger doesn't fire until the next full communication. What is the loop pattern number parameter set to?

I think my advice would be to change to Loop Lines and set the number to be 99 and in state 0 of the trigger get it to make a #temp trigger to match the next non communication line say perhaps your prompt and all it does is set the state of your comm trigger back to 0, #state 46 0, presuming the id of your comm trigger is 46.
_________________
Taz :)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Mon Oct 25, 2010 8:38 pm   
 
Is there something to indicate that a particular multiline is finished? For example, a blank line or the prompt? If so, a much better solution is to use a manual condition:

Code:
#trigger "name" {blah blah} {yakkity shmakkity}
#condition {^({whatever indicates end of multiline|%s[%x%s]})} {
  #if (%1 = whatever indicates end of multiline) {
    #state name 0
    stuff you want to do when trigger gets reset
  } {
    stuff you want to do to with multiline text
  }
}
_________________
EDIT: I didn't like my old signature
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