This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Colors!

Old posts that have not been replied to for several years.
Locked
X
Xabin

Colors!

Post by Xabin »

Yo!
I'm writing a script that will output some text to a user.
It also takes input from a user, and can display this too.
The problem arises when I want to color the output a bit.
Since the output contains numbers, the script "includes" the number in the color code. This is even more troublesome, since some of the variables it outputs sometimes contains numbers too.
Is there any way to "end" a color code, or some other solution?

For example, I want the script to output: "blah \0033$var\003", where $var = "0". For now I simply put a space between the color code and the variable.. but I would like a better solution.
Thanks in advance for any help. :]
p
ppslim
Revered One
Posts: 3914
Joined: Sun Sep 23, 2001 8:00 pm
Location: Liverpool, England

Post by ppslim »

Use fully qualifying colour codes.

IE.
IRC Colour codes use upto a 6 characters.
Char 1 = Colour code designator (Ascii code 003)
Char 2 & 3 = Forground colour code (See below colour chart)
Char 4 = Seperator (Comma - ascii code 044)
Char 5 & 6 = Backgroud colour code (See below colour chart)

Forground and background colour codes can be shortened to single codes.

There is no need to specify the background colour code, thus this can shorten it down to a minimum of 3 characters.

The following are the colour codes used in mIRC. However, they should apply to most clients (using double digit codes - as noted above, you can specify then as a single digit, if the first digit is 0)

0 White
1 Black
2 Blue
3 Green
4 Light Red
5 Brown
6 Purple
7 Orange
8 Yellow
9 Light green
10 Cyan
11 Light Cyan
12 Light Blue
13 Pink
14 Grey
15 Light Grey

In mIRC, but unknown in other clients, you can then start the sequence again, from 16, once to the end, start again and so on. EG 0 = White, 16 = White, 2 = Blue, 18 = Blue.

Again in mIRC, and unknown in other clients, you can use the colour code 99 to induce a transparrent colour.

This is the code you should want, to make a fully qualifying colour code, while not breaking the text in scripts.

EG.

For Blue text use "\00302,99"
X
Xabin

Post by Xabin »

Thank you very much! :)
Locked