Trying to capture lines with only one text colour

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Trying to capture lines with only one text colour

Post by Oneymus »

Taken straight from the manual, give this a try:
Code: [show] | [select all] lua
selectString( matches[1], 1 )
if isAnsiFgColor( 9 ) then
    echo( "First letter is light blue!\n" )
else
    echo( "This is some other colour.\n" )
end

Matak
Posts: 9
Joined: Thu Jun 23, 2011 11:41 pm

Re: Trying to capture lines with only one text colour

Post by Matak »

Tried that already and it didnt work but i gave it another go with what you supplied in case i messed something up originally.

Text from mud
This is some information from the mud

color trigger on blue (colors in this post wont be exactly accurate)
Code: [show] | [select all] lua
selectString( matches[1], 1 ) -- here matches[1] is [color=#0000FF]information[/color]and not the first character of the line
if isAnsiFgColor( 9 ) then --Always matching as its not working on the entire line.
    echo( "First letter is light blue!\n" ) 
else
    echo( "This is some other colour.\n" )
end
Appreciate the help.

User avatar
Oneymus
Posts: 321
Joined: Thu Sep 17, 2009 5:24 am

Re: Trying to capture lines with only one text colour

Post by Oneymus »

Ah. Then you may want to use a Regex trigger with pattern (.+). Not very efficient, but it will trigger on every line. You can then manipulate via Lua as you want; the code I posted -should- work.

To be honest, I haven't spent much time with isAnsiFgColor(), so I'm just going by what the manual says it does. Heh.

Matak
Posts: 9
Joined: Thu Jun 23, 2011 11:41 pm

Re: Trying to capture lines with only one text colour

Post by Matak »

OK I found out how to do what i was after.
Thanks to everyone for the ideas and assistance.
This is how i did it in the end - may help someone else.

I used a perl regex trigger of "\s*\w"

Then in script the following
Code: [show] | [select all] lua
selectString( matches[1], 1 )

if isAnsiFgColor( 8 ) then 
	selectCurrentLine()
        process this

elseif isAnsiFgColor( 5 ) then 
	selectCurrentLine()
	if (string.find(line, '"')) then --this makes sure the line has a double quote
        process this
	end
elseif isAnsiFgColor( 6 ) then -- tell
	selectCurrentLine()
        process this
end

Post Reply