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


Joined: 09 Sep 2010
Posts: 13

PostPosted: Sat Jun 02, 2012 6:03 pm   

problem with trigger ansi codes and some miscellaneous questions..
 
I have a trigger pair that looks up stats for items in database and appends it stats to the end of he item if it can find them
First one is finds the item in the database and prepares the string to be appended...
Code:

  <trigger priority="4460" regex="true" prompt="true" id="478">
  <pattern>^(\s+(?:\(Illusionary\)\s|\(Magical\)\s|\(Glowing\)\s|\(Humming\)\s)*+(?:a pair of |a set of |an |some |the |a )?(.*))</pattern>
  <value>dbvar = %find(%2,"All")
#IF (NOT %null(@dbvar)) {
    itemtext=""
    $stathp = %db(dbvar,hp)
    #if ($stathp) {itemtext = @itemtext + "hp:" +$stathp+" "}
    $statmana = %db(dbvar,mana)
    #if ($statmana) {itemtext = @itemtext + "mana:" +$statmana+" "}
    snipped for brevity .......
   
    itemtext = "<"+%ansi(yellow)%trim(@itemtext)+">"
}
{
    itemtext=""

}</value>
</trigger>


The second one works on the same pattern and just appends the "itemtext" to incoming line and relies on the first trigger to be executed first
(because I don't know if it's possible to use #sub in the value part of the same trigger)


Code:

<trigger name="stat4" priority="4700" regex="true" prompt="true" id="477">
  <pattern>^(\s+(?:\(Illusionary\)\s|\(Magical\)\s|\(Glowing\)\s|\(Humming\)\s)*+(?:a pair of |a set of |an |some |the |a )?(.*))</pattern>
  <value>#SUB {%1 @itemtext}
itemtext=""</value>
</trigger>


So when the Mud for example sends to following lines

<worn on finger> a golden ring set with a dragonseye
<worn on finger> (Glowing) a ring set with a flaming red ruby
<worn around neck> a fine leather cloak
<worn around neck> ---
<worn on body> a black breastplate

What I see on the screen is

<worn on finger> a golden ring set with a dragonseye <hp:15 mana:30>
<worn on finger> (Glowing) a ring set with a flaming red ruby <hp:10 mana:10>
<worn around neck> a fine leather cloak <unknown>
<worn around neck> --- <unknown>
<worn on body> a black breastplate <hp:10 hit:1 dam:2>

The whole line is captured as %1 and the "ring set with a flaming red ruby" is captured as %2 as it should be

So far so good, The problem is that "(Glowing)" part of the line is send in yellow color(Well I think..I have daltonism. :) ) and my triggers
substitute that with default gray color
Choosing "ANSI Trigger" option on both triggers causes lines to be displayed exactly as (This time "Glowing" is displayed in color though)

<worn on finger> a golden ring set with a dragonseye <hp:15 mana:30>
(Glowing) a ring set with a flaming red ruby <worn around neck> a fine leather cloak <unknown><worn around neck> ---
<worn on body> a black breastplate <hp:10 hit:1 dam:2>

I don't know what to do solve this problem. I think I need to incorporate that %e[xx stuff in the pattern somehow
but have no idea how.A few attempts resulted in failure..Any pointers would be greatly appreciated..

Onto my second question; I want to stats are displayed also in color, but in the first trigger if I use
Code:
itemtext = %ansi(yellow)"<"+%trim(@itemtext)+">"  (I want to make whole "itemtext" yellow)

I see;
<worn on finger><worn on finger> (Glowing) a ring set with a flaming red ruby <hp:10 mana:10>
So, I resort to
Code:
 itemtext = "<"+%ansi(yellow)%trim(@itemtext)+">"

This does what I want except the first "<" character but still no idea why..

On a unrelated note I've tried to use
@dbvar.hp notation instead of $stathp = %db(dbvar,hp) but couldn't read the Hp value
whatsoever. I am using CMUDPro 3.33a (16-12-2010)

Sorry for the verbose post, but I did not want to tire you for omitting some crucial information..
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Mon Jun 04, 2012 1:19 pm   
 
Yes, you need to incorporate the ansi codes into your trigger patterns. The easiest way is to get some mud text containining the color codes on your screen, open the Package Editor, start to create a new trigger, mark it as an ANSI trigger, then cut and paste the text into the trigger pattern. This should paste the correct escape codes into the pattern, and you can use those codes in your more complete pattern.
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