Trouble getting text colour

Posted by Shwick on Sat 29 May 2010 08:29 AM — 2 posts, 12,781 views.

#0
I'm trying to match the colour of text I receive from the mud.

I'm using world.GetLinesInBufferCount, world.GetStyleInfo and world.GetLineInfo.

The problem is the output buffer changes to rapidly that I can't detect the text I want.

Am I supposed to match the trig_line with a line from the output buffer by iterating through it?

I tried outputting the last 25 lines of the output buffer using GetLineInfo, counting from GetLinesInBufferCount - 25 to GetLinesInBufferCount.

The output was skipping lines from the screen, it was not sequential.

Is there a method that gets called when the output buffer changes, or am I going about this the wrong way.

for example, this never seems to work:


#check last line in the buffer for colour yellow
line = world.GetLinesInBufferCount - 1        
styleRuns = world.GetLineInfo (line, 11)
ansiColour = world.GetStyleInfo (line, styleRuns, 14)                
        if ansiColour == 65535:
                print('found')


wow my code tags aren't even working... im doing godlike tonight
Amended on Sat 05 Jun 2010 05:43 AM by Nick Gammon
Australia Forum Administrator #1
Shwick said:

Is there a method that gets called when the output buffer changes, or am I going about this the wrong way.


Yes, a trigger matching "*" would be called when new output arrives.

As for the colour, a trigger matching the text you want and matching the wanted colour would work, provided the very first matching character of the trigger is the one you want to check the colour of.