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
miconnor
Newbie


Joined: 27 Aug 2008
Posts: 5

PostPosted: Wed Aug 27, 2008 3:38 am   

Saving ansi info in variable
 
I'm using a trigger that captures text and saves it to a variable. Is there any way for CMUD to save the ansi color of the text that is being captured?
Reply with quote
miconnor
Newbie


Joined: 27 Aug 2008
Posts: 5

PostPosted: Wed Aug 27, 2008 3:47 am   
 
Just for reference, here is the trigger I'm using.

Pattern:
Code:

^%1$


Script:
Code:

#IF %1=~"< %nh/%nH %nv/%nV Pos:*>"
{
   #T- identify_DB_class_capture
   #T- identify_DB_class
 }
{
  #var str_cap %1
  #print Capture String = @str_cap
}
Reply with quote
Merilix
Beginner


Joined: 20 Aug 2008
Posts: 24
Location: Germany

PostPosted: Wed Aug 27, 2008 4:04 am   
 
You could try something like this
Code:
<trigger priority="2120" ansi="true" trigontrig="false" id="212">
  <pattern>%e[(%d)S(*)%e[0m</pattern>
  <value>colorcode=%1
text=%2</value>
</trigger>
Reply with quote
Rahab
Wizard


Joined: 22 Mar 2007
Posts: 2320

PostPosted: Wed Aug 27, 2008 5:29 pm   
 
To explain:
You don't use %1, %2, etc. within trigger patterns. Instead you put the part you want to capture within parentheses, (whatever). Within the script body, you then use %1 to refer to the part captured by the first parentheses, %2 for the second parentheses, etc. In the trigger pattern, the capture parentheses can go around any valid trigger pattern. (*) will capture anything. (%w %w) will capture two words. (Rahab's %w) will capture the text "Rahab's" followed by one word.

Are you trying to capture just the ansi code for the color? This is the pattern I would use: (%e[%dm)
That evaluates to 'ESC', '[', a number, and the letter m. Modify this to suit your needs. You could explain further what exactly you are trying to capture, and give us some examples, and we could suggest something.
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