Help coloring text

Posted by Ashass on Tue 28 Dec 2010 08:11 AM — 5 posts, 26,762 views.

#0
Been working on this for a bit now, finally got it to match everything right, except now I need to color the trigger text (but only when it matches the criteria that triggers the 'Enemy sighted!' message box.)

Trigger text:
* is here*


Guts:
Dim db
Dim rs
Dim SQL
Dim check_enemy
Dim SplitName
Dim get_enemies

get_enemies = world.GetVariable ("War_Clan_List")

check_enemy = "%1"
check_enemy = Trim(check_enemy)
Do While InStr(1, check_enemy, "  ")
  check_enemy = Replace(check_enemy, "  ", " ")
Loop
Do While InStr(1, check_enemy, " ")
  check_enemy = Replace(check_enemy, " ", "___")
Loop

SplitName = Split(check_enemy, "___")

Set db = CreateObject("ADODB.Connection")
db.Open "DSN=ODBC_DRIVER;UID=USERNAME;PWD=PASSWORD;Database=DATABASE"
SQL = "SELECT affiliation FROM dsl.dbo.users WHERE username = '" & replace(SplitName(0), "'", "") & "'"
Set rs = db.Execute (SQL)

If Not (rs.BOF And Not rs.EOF) Then
  If (instr(get_enemies, rs("affiliation") )) Then
    MsgBox "Enemy Sighted!"
  End If
End If

rs.Close
Set rs = Nothing
db.Close
Set db = Nothing
Amended on Tue 28 Dec 2010 08:12 AM by Ashass
Australia Forum Administrator #1
You could have the trigger omit from output, to get rid of the original, and the ColourNote with your desired colours, the original text which will be %0.
#2
Worked beautifully. Thanks!

Hum, actually, small problem.. Other things have 'is here' in there, so I need to be able to... un omit them from output if they don't match the database, any idea how to do that?

=======

Nm, i got it,

If Not (rs.EOF) Then
  If (instr(get_enemies, rs("affiliation"))) Then
    world.ColourNote "black", "red", "%0"
  Else
    world.ColourNote "black", "green", "%0"
  End If
Else
  world.ColourNote "black", "gray", "%0"
End If


now i just need to find colors that aren't offensive...
Amended on Wed 29 Dec 2010 05:52 AM by Nick Gammon
#3
Nick, is there a way to preserve the original line colors? That way when I omit the line I can color the name, then have the rest of the line the proper color?

I already have how to split out the name from the rest of the line, so all I need to know is how to retrieve the normal line color =)
Australia Forum Administrator #4
It's easier in Lua <sigh> because the trigger can get the style runs which have the colours in them.

However you can get style runs of the last line ...

Template:function=GetStyleInfo
GetStyleInfo

The documentation for the GetStyleInfo script function is available online. It is also in the MUSHclient help file.



That gives you the colours which you can put back into your ColourNote calls.