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
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Thu Jan 13, 2011 2:41 pm   

Consolidating Repeats... Where did I go wrong?
 
Okay, so I made a class to reduce screen scroll when i have the same items over and over as follows:

Code:

<class name="Repeaters" id="43">
  <trigger priority="440" id="44">
    <pattern>^*%w*$</pattern>
    <value>#IF (%line=@lastLine) {#ADD lineRepeats 1} {lineRepeats=0}
#IF (@lineRepeats) {
  #GAG -1
  #SAYADD { (x%eval(@lineRepeats+1))}
  }
lastLine=%line</value>
  </trigger>
  <var name="lineRepeats" id="46">58</var>
  <var name="lastLine" id="47">Testing.</var>
  <alias name="repTest" id="331">
    <value>#30 {#SAY {Testing.}}</value>
  </alias>
</class>


And it seems to work great... However, for some reason it is gagging more than it is supposed to, can anyone tell me why?

it turns this

Code:

A sturdy oak tool rack stands near the doorway.
A small burlap bag lies here. (x323)
A large pile of loose hay sprawls here. (x266)
A large, heavy stone chest stands in a corner.
The hayloft is freshly filled with hay.
There is a simple wooden stool here.
A small sack filled with fertiliser has been left here. (x4)
The barn floor is quite dirty and in need of sweeping.
A dirty bucket has been set here.
The cow stalls are in need of cleaning.
The cow stalls are in need of cleaning.
The cow stalls are in need of cleaning.
The cow stalls are in need of cleaning.
A wooden torch, its tip wrapped in an oil soaked cloth, lies here.
A wide, wooden bin marked Gross Eggs sits here.
A two-wheeled, wooden push-cart is here.
A plain wooden barrel marked Finished Marketable Goods sits here.


into this

Code:

A sturdy oak tool rack stands near the doorway.
A small burlap bag lies here. (x323)
A large pile of loose hay sprawls here. (x266)
A large, heavy stone chest stands in a corner.
The hayloft is freshly filled with hay.
There is a simple wooden stool here.
A small sack filled with fertiliser has been left here. (x4)
The barn floor is quite dirty and in need of sweeping.
A dirty bucket has been set here.
The cow stalls are in need of cleaning.  (x4)
A plain wooden barrel marked Finished Marketable Goods sits here.


As you can see, the second example is missing everything between the dirty cow stalls and the barrel.
Yet those should have never matched the repeat trigger to gag them.
_________________
Discord: Shalimarwildcat
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Thu Jan 13, 2011 4:39 pm   
 
If you take the class code you posted, and put that in the untitled session. Then paste the first block of example text into the editor and send it to CMUD.
Prefix:
Code:
#SHOW {

Suffix:
Code:
}

The lines get combined and gagged properly with nothing else getting gagged that shouldn't be. That said I'd start to test for other triggers interfering.

Many of the items in the example text look familiar. If I remember correctly, the MUD I recall seeing such items on would not cause triggers to fire sometimes when the pattern was anchored at the end of the line. That may be something to look into aswell.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Thu Jan 13, 2011 6:31 pm   
 
Given that the pattern also has * in it before and after the word, the anchors should be more or less meaningless.

I changed the pattern to just %w and the priority to 99999999 and it seems to be working fine, so far.
_________________
Discord: Shalimarwildcat
Reply with quote
Fizgar
Magician


Joined: 07 Feb 2002
Posts: 333
Location: Central Virginia

PostPosted: Thu Jan 13, 2011 8:44 pm   
 
The way I understand priority, the higher the number is set to, the the further down the list of triggers it will be tested. An example.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <class name="PriorityTest" copy="yes">
    <trigger name="2" priority="2" copy="yes">
      <pattern>^test$</pattern>
      <value>#print 2 fired</value>
    </trigger>
    <trigger name="1" priority="1" copy="yes">
      <pattern>^test$</pattern>
      <value>#print 1 fired</value>
    </trigger>
    <alias name="test" copy="yes">
      <value>#show test</value>
    </alias>
  </class>
</cmud>

Above is an alias and two triggers. The trigger I gave an id of 1 to has it's priority set to 1 and the trigger with it's id set to 2 has a priority of 2. Typing test will print 1 fired followed by 2 fired. Change the priority of trigger with the id of 1 to 3 and type test again 2 fired followed by 1 fired will be printed to the screen.

With that logic, changing the priority of your trigger to 99999999 made it the last trigger to be tested for, unless you have settings with a higher priority than 99999999. In my opinion that would rule out that there were previous triggers interfering since now everything will be tested before the original trigger. Had you changed the priority to the lowest number possible that would be a different story. To me, that makes it look like the anchors were causing the problem.
_________________
Windows Vista Home Premium SP2 32-bit
AMD Athlon Dual Core 4400+ 2.31 GHz
3 GB RAM
CMUD 3.34
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Thu Jan 13, 2011 8:57 pm   
 
I agree, but with * i don't see how the anchors mattered at all.
_________________
Discord: Shalimarwildcat
Reply with quote
shalimar
GURU


Joined: 04 Aug 2002
Posts: 4692
Location: Pensacola, FL, USA

PostPosted: Thu Jan 13, 2011 11:23 pm   
 
It is still messing up.
I even tried changing the priority to 1 so it runs first... I still have it occasionally gobbling up extra lines when it shouldn't.

This is on the Shadows of Isildur MUD.
_________________
Discord: Shalimarwildcat
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Fri Jan 14, 2011 3:17 pm   
 
Have you checked whether any other triggers might be gagging those other lines? The output you show does not seem to indicate this trigger is doing it. It correctly gives a x4 for the number of line duplicated. Have you checked the debugger to see what is executing?
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