[Home] [Downloads] [Search] [Help/forum]

Gammon Forum

See www.mushclient.com/spam for dealing with forum spam. Please read the MUSHclient FAQ!

[Folder]  Entire forum
-> [Folder]  MUSHclient
. -> [Folder]  VBscript
. . -> [Subject]  Help coloring text
Home  |  Users  |  Search  |  FAQ
Username:
Register forum user name
Password:
Forgotten password?

Help coloring text

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page


Posted by Ashass   (50 posts)  [Biography] bio
Date Tue 28 Dec 2010 08:11 AM (UTC)

Amended on Tue 28 Dec 2010 08:12 AM (UTC) by Ashass

Message
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
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #1 on Tue 28 Dec 2010 08:31 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

Posted by Ashass   (50 posts)  [Biography] bio
Date Reply #2 on Tue 28 Dec 2010 08:53 AM (UTC)

Amended on Wed 29 Dec 2010 05:52 AM (UTC) by Nick Gammon

Message
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...
[Go to top] top

Posted by Ashass   (50 posts)  [Biography] bio
Date Reply #3 on Tue 28 Dec 2010 07:35 PM (UTC)
Message
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 =)
[Go to top] top

Posted by Nick Gammon   Australia  (21,322 posts)  [Biography] bio   Forum Administrator
Date Reply #4 on Wed 29 Dec 2010 05:54 AM (UTC)
Message
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.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
[Go to top] top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


4,315 views.

It is now over 60 days since the last post. This thread is closed.     [Refresh] Refresh page

Go to topic:           Search the forum


[Go to top] top

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]