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
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Nov 05, 2010 7:06 pm   

Ansi Trigger Help
 
Okay I have shalimar's SOI Helper package and I want to try to get the trigger to be more specific. Here is the trigger:
Code:

<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger name="CraftUser" priority="200" case="true" repeat="true">
    <pattern>%q({@craftList})%q</pattern>
    <value><![CDATA[$color=SlateGray
$task = {@craftList.%1}
#sub {<send 'mat %1~|$task %1' 'Materials for %1~|Perform $task %1'><color $color>%1</color></send>}]]></value>
  </trigger>
</cmud>


Now I want it to be ansi trigger. So I checked the Ansi trigger option, then selected the color and checked the line color checkbox.

Now when the trigger fires it messes up the format of the word.
Example before turning to ansi trigger:
A brass lantern sits here, its slides closed.
Example after turning to ansi trigger:
A brass lantelantern here, its slides closed.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)

Last edited by darmir on Fri Nov 05, 2010 10:47 pm; edited 1 time in total
Reply with quote
shalimar
GURU


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

PostPosted: Fri Nov 05, 2010 9:13 pm   
 
The problem is that crafts are shown in two separate colors.

The crafts listed Via 'crafts craftset' are the dark teal color
The crafts listed via EXAM or ORIG tend to be your standard white/silver color.

On top of that, I myself have never been able to get ansi triggers to fire properly.
_________________
Discord: Shalimarwildcat
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Nov 05, 2010 9:16 pm   
 
shalimar wrote:
The problem is that crafts are shown in two separate colors.

The crafts listed Via 'crafts craftset' are the dark teal color
The crafts listed via EXAM or ORIG tend to be your standard white/silver color.

On top of that, I myself have never been able to get ansi triggers to fire properly.


shalimar,
I was seeing if it would fire for only green words. I wasn't testing for the others. I was just playing around with it to see if I can just get the trigger to only fire in the list of object in the floor, which are the green color.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
shalimar
GURU


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

PostPosted: Fri Nov 05, 2010 10:09 pm   
 
i went so far as to create a new trigger

Code:
<trigger priority="1" ansi="true" id="310">
  <pattern>%e[32m%q({@craftList})%q%e[0m</pattern>
  <value>#SAY color trigger worked</value>
</trigger>


Using the ansi codes i recieved off of createing a new ansi trigger from a highlighted string.

Code:
<trigger priority="3100" ansi="true" id="310">
  <pattern>%e[32mA small burlap bag lies here.%e[0m $</pattern>
  <value>#SAY color trigger worked</value>
</trigger>


While using the original string it worked fine, but when i change to the pattern from the package, it fails.

Maybe there is a problem with using ansi codes and complex patterns?
_________________
Discord: Shalimarwildcat
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Fri Nov 05, 2010 10:55 pm   
 
shalimar,
I think there something wrong with ansi triggers. I did the following steps to create an ansi trigger and it did not fire.

1) Create a new ANSI Trigger with a blank pattern.
2) Then copy the line from the MUD that you want to match and paste it into the Pattern field. Have the ANSI Trigger option enabled
-- CMUD will display the ANSI color codes contained in the line from the MUD.
When I reviewed my trigger patten is showed the following:
Code:
%e[32mA wooden pantry stands against the wall%e[0m

3) To test just add #print test in the text script
4) Run your command from your mud to generate the line to trigger the line.

Nothing is displayed.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
shalimar
GURU


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

PostPosted: Fri Nov 05, 2010 11:33 pm   
 
If you notice my example uses the entire line. I bet adding in the period will fix yours.

This is pure speculation mind you but this is where I think the problem lies:

Since the whole line has the color, if you miss the opening or closing ansi codes from the mud in your pattern, then it doesn't match.

Logically the pattern is looking for {Just $this is green} instead of {Just $this, if its green}.
_________________
Discord: Shalimarwildcat
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Nov 06, 2010 4:05 pm   
 
Quote:

think there something wrong with ansi triggers.


There's nothing wrong with the ansi trigger functionality; it's simply that your pattern is "wrong". Despite the visual effect, %e[32m is not the same as %e[0;32m according to the trigger parser. You can use the Script Debugger to check for differences between your copy-pasted pattern and the actual line sent by the game.
_________________
EDIT: I didn't like my old signature
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Nov 06, 2010 4:16 pm   
 
MattLofton wrote:
Quote:

think there something wrong with ansi triggers.


There's nothing wrong with the ansi trigger functionality; it's simply that your pattern is "wrong". Despite the visual effect, %e[32m is not the same as %e[0;32m according to the trigger parser. You can use the Script Debugger to check for differences between your copy-pasted pattern and the actual line sent by the game.


Okay.. I turned on the #debug and this is what the mud is sending:
Code:
<ESC>[32mA wooden pantry stands against the wall.<ESC>[0m

So then what do I put in to get the ansi trigger to match!

What I put in my example step is what the MUD gave me when I copied and pasted the string. So then how can I be wrong? I took those instructions from another thread that Zugg said how to get an ansi trigger to work, but it didn't. See quote below:
Zugg wrote:
Create a new ANSI Trigger with a blank pattern. Then copy the line from the MUD that you want to match and paste it into the Pattern field. If the ANSI Trigger option is enabled, CMUD will display the ANSI color codes contained in the line from the MUD.

Recent versions of CMUD fixed some bugs with ANSI color codes getting stripped from the beginning of lines, so my guess is that there is an ANSI code at the beginning of the line or elsewhere on the line that is different than what you used to have.

If that doesn't work, than post the text from the MUD that you are trying to trigger on.

Oh, and you don't need to quote the [ character that comes after a %e. CMUD has a special case coded into it so that a [ character after %e is automatically escaped.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
MattLofton
GURU


Joined: 23 Dec 2000
Posts: 4834
Location: USA

PostPosted: Sat Nov 06, 2010 4:52 pm   
 
Quote:

So I checked the Ansi trigger option, then selected the color and checked the line color checkbox.


This might be a contender for the original post, but I noticed in your later work you didn't mention it. ANSI triggers don't need the Line Color option checked, and I dunno if having the ANSI trigger option causes the Line Color to be ignored. If it's not, this could cause a matching conflict.

Beyond that, perhaps the %q is messing up the detection? This wildcard might not be necessary in this application when ansi codes are involved, so it could be forcing the parser to look for something that's not actually there (ergo, no match). This, of course, would not be related to the working status of ansi triggers and my original statement would still stand. Wink

The only other thing I noticed was that the last trigger you posted code for had a space between the closing ansi code and the end-of-line anchor, while the one before that didn't. If there's a space there, then obviously your trigger looking for the EOL right at the boundary of {@craftlist} would not match.
_________________
EDIT: I didn't like my old signature
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Nov 06, 2010 5:55 pm   
 
Matt,
I tried match just a single word using Zuggs direction from my mud and it won't match. So I still think there is an issue with ansi triggers.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Sat Nov 06, 2010 6:14 pm   
 
Try your ansi trigger without the %e[0m at the end of the pattern, darmir. If you are only trying to match part of a line, instead of a whole line in which the %e[0m only appears at the end, you need to leave that out.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Nov 06, 2010 6:27 pm   
 
DraxDrax wrote:
Try your ansi trigger without the %e[0m at the end of the pattern, darmir. If you are only trying to match part of a line, instead of a whole line in which the %e[0m only appears at the end, you need to leave that out.

Actually I am trying to match a word within the line, but I was testing with the whole line. So if the line says:

A firewood box is set in one corner.

Then just match the word: firewood

See the above match for craftList variable
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Sat Nov 06, 2010 6:52 pm   
 
Can you post the value of the @craftlist variable?

Will the materials you're trying to match, like the example 'firewood' always be the same color?
edit: reading Shalimar's post, it appears they will not...
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Nov 06, 2010 7:06 pm   
 
Removed didn't fit. Reposted below
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)

Last edited by darmir on Sat Nov 06, 2010 7:14 pm; edited 1 time in total
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Nov 06, 2010 7:14 pm   
 
The craftList variabe to big to fit here. So I PM'd it to you. You can get this package from the package library is it called SOI-Helper. Under the mud Shadows of Isildur

There are two colors which they can match to. They are:
green - %e[32m
darkcyan - %e[36

Example outputs are:
Code:

   sweep street                            prepare volunteers-crate     
   make unmade-beds                  remove soiled-linens         
   work logging-camp                   trade foraged-grubs           
   unstack federation-shipment     load federation-crate         
   divide alum-barrel                    clean animal-stains           
   divide bagged-ore                    cut bandages                 
   sweep barn-floor                      fill barrel-with-water

and
Code:

Am uncured feta-cheese wheel lies here.
Am uncured feta-cheese wheel lies here.
A two-wheeled, wooden push-cart is here.
A plain, watertight bucket is set here.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Sat Nov 06, 2010 8:44 pm   
 
K, I've been able to reproduce your results and it looks like a bug with the combination of an ansi trigger and the #SUB command. #SUB is including the length of any ansi escape codes preceding the string you want to substitute when it calculates where to perform the substitution, consequently, if the color of the line is being changed, the substituted string, like 'lantern', is shifted several characters to the right of where it should be. I'd say that counts as a bug. Zugg should have no trouble fixing it though.

I tried jury rigging a solution with #PSUB, which lets you more precisely control where on the line you're replacing things, but #PSUB doesn't appear to work with mxp tags. I think you may be out of luck doing this with ansi triggers, darmir.

In your first post, you describe trying to make the trigger more specific. What benefit do you hope to get from a more specific trigger? Perhaps there's a way to do it that doesn't involve ansi triggers.
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Sat Nov 06, 2010 9:09 pm   
 
DraxDrax wrote:
In your first post, you describe trying to make the trigger more specific. What benefit do you hope to get from a more specific trigger? Perhaps there's a way to do it that doesn't involve ansi triggers.


The reason I was trying to make them more specific, which shalimar already knows and tried also, is the way the pattern matches it subsitutes any of those strings which we only want in for the two instances that I displayed above.
Now the trigger changes things like:

Farming-general: gather honey
Usable During: Summer Spring Autumn
Phase 1: 30 seconds
Held or in Room (Consumed): a busy apiary.
Held or in Room (Consumed): a ceramic jar.
Produced: a tall apiary.
Phase 2: 40 seconds, Farming skill utilized.
Phase 3: 15 seconds
Produced: a large jar of honey.
Produced: 6 of a lump of beeswax.

and


gather honey(a bunch of spaces) cut small-red-seed-potatoes
arrange haystack-pile(a bunch of spaces) milk ewe-nanny


and

A honey-haired, blue-eyed woman

Now we don't want it to match on the last instance.
PS. The reason I didn't put the above in bbcode is it wouldn't display the colors inside the code type.
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Sat Nov 06, 2010 9:46 pm   
 
Might something like this work? It appears to do the trick for me with the examples you provided.

Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger name="CraftGroups" priority="80" ansi="true" repeat="true" copy="yes">
    <pattern>%q({@craftAreas})%q</pattern>
    <value><![CDATA[$color=goldenrod
#SUB {<send 'crafts %1' 'Can i do any %1 crafts?'><color $color>%1</color></send>}]]></value>
  </trigger>
  <class name="Craft_Triggers" initdisable="true" enabled="false" copy="yes">
    <trigger name="CraftGroups" priority="80" ansi="true" repeat="true" copy="yes">
      <pattern>%q({@craftAreas})%q</pattern>
      <value><![CDATA[$color=goldenrod
#SUB {<send 'crafts %1' 'Can i do any %1 crafts?'><color $color>%1</color></send>}]]></value>
    </trigger>
    <trigger name="CraftUser" priority="90" case="true" ansi="true" repeat="true" copy="yes">
      <pattern>%q({@craftList})%q</pattern>
      <value><![CDATA[$color=slategray
$task = {@craftList.%1}
#SUB {<send 'mat %1|#EXEC {$task %1}' 'Materials for %1|Perform $task %1'><color $color>%1</color></send>}]]></value>
    </trigger>
    <trigger priority="140" copy="yes">
      <pattern>^$</pattern>
      <value>#T- Craft_Triggers</value>
    </trigger>
  </class>
  <trigger name="CraftUser" priority="90" case="true" ansi="true" repeat="true" copy="yes">
    <pattern>%q({@craftList})%q</pattern>
    <value><![CDATA[$color=slategray
$task = {@craftList.%1}
#SUB {<send 'mat %1|#EXEC {$task %1}' 'Materials for %1|Perform $task %1'><color $color>%1</color></send>}]]></value>
  </trigger>
  <trigger name="MatchCraft1" priority="80" copy="yes">
    <pattern>%x   %s%x</pattern>
    <value>#T+ Craft_Triggers</value>
  </trigger>
  <trigger name="MatchCraft2" priority="80" copy="yes">
    <pattern>[A-z-]: [A-z- ]</pattern>
    <value>#T+ Craft_Triggers</value>
  </trigger>
</cmud>


This involves moving the triggers CraftList and CraftUser to a new class and leaving the class they are in disabled most of the time. The two new triggers I've created, called MatchCraft1 and MatchCraft2 match the sorts of lines you want parsed and enable the 'Craft_Triggers' class, which then lets CraftList and CraftUser do their work on the lines you want. When a blank line is encountered they get switched off again.
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Nov 08, 2010 3:04 pm   
 
Darmir, earlier you said:
Quote:

Okay.. I turned on the #debug and this is what the mud is sending:
Code:
<ESC>[32mA wooden pantry stands against the wall.<ESC>[0m

So then what do I put in to get the ansi trigger to match!

The answer is that you have to use
Code:
%e[32mA wooden pantry stands against the wall.%e[0m

Your earlier trigger was missing the period before the last escape, so it wouldn't match. An ansi trigger will match ansi codes only _exactly_ where the ansi code appears in the mud text. If the escape occurs after the period, then it won't match if you put the escape before the period in your trigger pattern. If you don't want to match against the period, you don't have to have the closing ansi code. If you just want to match the first part, you could make your pattern just:
Code:
%e[32mA wooden pantry

If you are just trying to match against a single word, you can do that. But note that if you are trying to capture just the word "pantry", for instance, it won't capture the ansi codes unless you capture the entire text out to the ansi codes.
Reply with quote
shalimar
GURU


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

PostPosted: Mon Nov 08, 2010 4:30 pm   
 
So pretty much exactly what I speculated.
_________________
Discord: Shalimarwildcat
Reply with quote
darmir
Sorcerer


Joined: 10 Oct 2000
Posts: 706
Location: USA

PostPosted: Mon Nov 08, 2010 4:38 pm   
 
Rahab wrote:
An ansi trigger will match ansi codes only _exactly_ where the ansi code appears in the mud text. If the escape occurs after the period, then it won't match if you put the escape before the period in your trigger pattern. If you don't want to match against the period, you don't have to have the closing ansi code. If you just want to match the first part, you could make your pattern just:
Code:
%e[32mA wooden pantry

If you are just trying to match against a single word, you can do that. But note that if you are trying to capture just the word "pantry", for instance, it won't capture the ansi codes unless you capture the entire text out to the ansi codes.

Thank Rahab, I didn't know you had to do ansi triggers that way.
So back to my first post of the thread then why does it display that way?

See below: The word lantern is messing up.
A brass lantern sits here, its slides closed.
Example after turning to ansi trigger:
A brass lantelantern here, its slides closed.

Here is the code when you check the color checkbox.
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger name="CraftUser" priority="200" case="true" repeat="true" linecolor="2">
    <pattern>%q({@craftList})%q</pattern>
    <value><![CDATA[$color=SlateGray
$task = {@craftList.%1}
#sub {<send 'mat %1~|$task %1' 'Materials for %1~|Perform $task %1'><color $color>%1</color></send>}]]></value>
  </trigger>
</cmud>
_________________
Run as hard as a wild beast if you will, but you won't get any reward greater than that destined for you.
Source: (Egyptian)
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Nov 08, 2010 4:54 pm   
 
This trigger is not an ansi trigger. An ansi trigger is one that tries to match ansi codes within the pattern. You don't have any ansi codes within your pattern, so you should turn off the ansi trigger box.

I believe the color box has a completely separate functionality from the ansi trigger checkbox. I haven't played with it much, but as I recall, by setting the color box, it means the pattern will only match text which is in that color. I believe the color box should _not_ be used in conjunction with the ansi trigger checkbox, but as I said, I haven't played with the color box much. I might be wrong. But try it with the color box set and the ansi trigger turned off.

[edit]If I'm right, the problem you are getting is that the ansi checkbox is interfering with the color box. The color box is correctly finding the right word, and how far into the line it is, but then the ansi trigger is making the ansi codes visible to the trigger, throwing the position count off. If this is what's happening, it probably should be considered a bug, but you generally shouldn't be using both the color box and the ansi trigger checkbox at the same time.
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Mon Nov 08, 2010 5:17 pm   
 
The bug you describe... and I described six posts ago... is exactly what is happening, Rahab, but it occurs in any ansi trigger that uses the #SUB command, whether 'line color' is clicked or not.

Is there a preferred method for reporting bugs like this?
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Nov 08, 2010 5:40 pm   
 
The preferred method is to post here, with explicit details of how to recreate it (in a blank session if possible), and any necessary support showing what is happening if needed.

I still don't see why you want that to be an ansi trigger when you aren't triggering on ansi codes. Using an ansi trigger when you aren't matching ansi codes is liable to mess you up badly.

On the other hand, I've used #sub with ansi triggers before and not had a problem. Can you post a code example which is a proper ansi trigger showing this problem? None of the code you have posted so far does this.
Reply with quote
DraxDrax
Apprentice


Joined: 22 Mar 2009
Posts: 149

PostPosted: Mon Nov 08, 2010 5:56 pm   
 
Code:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<cmud>
  <trigger priority="10" ansi="true" copy="yes">
    <pattern>%e[1;33mstring</pattern>
    <value>#SUB {foo}</value>
  </trigger>
  <alias name="test" copy="yes">
    <value>#SHOW A line with no color before the %e[1~;33mstring is shifted 4 characters to the right.
#SHOW %e[1~;34mA line with one color before the %e[1~;33mstring shifts the sub 7 characters to the right.
#SHOW %e[1~;34mA line with two %e[0~;35mcolors before the %e[1~;33mstring shifts the sub 14 characters to the right.</value>
  </alias>
</cmud>



There you go, a proper ansi trigger. Copy / paste in a clean installation of 3.31 and type 'test'.
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