How To ANSI

From Fate's Harvest
Jump to: navigation, search

So You Want To Play With ANSI

Promise, it isn't arcane wizardry. It's really pretty simple.

To start off with, there are three types of ANSI colour codes: ANSI 16, HTML 256 and RGB decimal vectors.

The very top table on this page shows you the basic 16 colours ANY MU* client can view.
(Clients like, for example, SimpleMU are too out of date to view HTML 256 or RGB decimals.)

This information is available in non-wiki form within any TinyMUX game's default 'help' system as the following, sometimes much more elaborate, helpfiles:

help ansi
help ansi()
help ansi codes
help ansi substitution



Basic ANSI

Say you have a comtitle, and you want it to be red. The way the code works, you can do this in one of two ways: you can use substitutions, or you can use a function.

Quick explanation:

Substitution = shortcut text starting with %x
Function = those things that end in () like ansi() and do mysterious magical code stuff

The way functions work, all the codestuff gets tucked away between the ().

For things like comtitles, it tends to be easier to use substitutions. They're quicker to type and you don't have to remember all sorts of [ and / and , and ) to make them work.

See the helpfiles below for code:

ANSI CODES

       f - flash                       i - inverse
       h - highlight                   n - normal
       u - underline

       x - black foreground            X - black background
       r - red foreground              R - red background
       g - green foreground            G - green background
       y - yellow foreground           Y - yellow background
       b - blue foreground             B - blue background
       m - magenta foreground          M - magenta background
       c - cyan foreground             C - cyan background
       w - white foreground            W - white background

       <#RRGGBB> HTML color code
       <R G B>   RGB decimal vector
       /         Background indicator prefix

 Examples:
     ansi(fc, Test) would highlight "Test" is flashing cyan.
     ansi(<#FF8040>/<#800080>, Test) uses Orange on Dark Purple.
     ansi(<255 153 153>/<255 255 153>, Test) uses pale red on pale yellow.

The information above is located in 'help ansi codes' IG.

Each of those letters stands for a particular colour in standard ANSI 16. By default, they are the "dark" colours. If you "highlight" them, they are the bright version of those colours.

ANSI SUBSTITUTION

 The ANSI percent substitutions (%x, %X, %c, and %C) can be used instead of
 ansi(), and they are more efficient.  For example, the equivalent to
 '[ansi(rBf,Color!)]' would be: '%xr%xB%xfColor!%xn'.  The %xn (return to
 normal) is understood and therefore optional.

 %x is equivalent to %c, and %X is equivalent to %C, however, translate()
 always produces sequences of %x and %X. So, %x and %X are 'preferred'.

 The color code following %x or %X can be:

   Single letter (%xb, %xc, %xf, %xg, %xh, %xi, %xm, %xn, %xr, %xu, %xw, %xx,
     %xy, %xB, %xC, %xG, %xM, %xR, %xW, %xX, and %xY)

   HTML color code (%x<#RRGGBB> or %x<#000000> through %x<#FFFFFF>)

   RGB decimal vector (%x<R G B> or %x<0 0 0> through %x<255 255 255>)

 Red, Green, and Blue are abbreviated as R, G, and B.

 For the single-letter form, the case of the letter determines whether the
 color specifies foreground (lower-case) or background (upper-case).  For the
 HTML and decimal-vector forms, the case of the %x or %X determines whether
 the specified color is foreground or background.

The file above is located in 'help ansi substitution' IG.

Depending on your client's configuration, be warned -- UNHIGHLIGHTED black may show up as .. well, black. Typically, most people go into their client's settings and turn ANSI black into a really dark grey instead. In the example below, I have made it #303030 instead of #000000 for visibility's sake.

ANSI 16 text on a black background:

ANSI 16 ANSI 16
%xx      [ansi(x,TEXT)] %xh%xx      [ansi(hx,TEXT)]
%xr      [ansi(r,TEXT)] %xh%xr      [ansi(hr,TEXT)]
%xg      [ansi(g,TEXT)] %xh%xg      [ansi(hg,TEXT)]
%xy      [ansi(y,TEXT)] %xh%xy      [ansi(hy,TEXT)]
%xb      [ansi(b,TEXT)] %xh%xb      [ansi(hb,TEXT)]
%xm      [ansi(m,TEXT)] %xh%xm      [ansi(hm,TEXT)]
%xc      [ansi(c,TEXT)] %xh%xc      [ansi(hc,TEXT)]
%xw      [ansi(w,TEXT)] %xh%xw      [ansi(hw,TEXT)]

Backgrounds:      Note that backgrounds in ANSI 16 cannot be highlighted.

ANSI 16
%xX      [ansi(X,TEXT)]
%xR      [ansi(R,TEXT)]
%xG      [ansi(G,TEXT)]
%xY      [ansi(Y,TEXT)]
%xB      [ansi(B,TEXT)]
%xM      [ansi(M,TEXT)]
%xC      [ansi(C,TEXT)]
%xW      [ansi(W,TEXT)]

HTML 256 text on a black background:

HTML 256 HTML 256
%x<#5f00ff>      [ansi(<#5f00ff>,TEXT)] %x<#0087d7>      [ansi(<#0087d7>,TEXT)]
%x<#00af87>      [ansi(<#00af87>,TEXT)] %x<#afd700>      [ansi(<#afd700>,TEXT)]
%x<#ffd700>      [ansi(<#ffd700>,TEXT)] %x<#ff8700>      [ansi(<#ff8700>,TEXT)]

HTML 256 backgrounds with ANSI Black text:

HTML 256 HTML 256
%X<#5f00ff>      [ansi(x/<#5f00ff>,TEXT)] %X<#0087d7>      [ansi(x/<#0087d7>,TEXT)]
%X<#00af87>      [ansi(x/<#00af87>,TEXT)] %X<#afd700>      [ansi(x/<#afd700>,TEXT)]
%X<#ffd700>      [ansi(x/<#ffd700>,TEXT)] %X<#ff8700>      [ansi(x/<#ff8700>,TEXT)]

RGB Decimal text on a black background:

RGB Decimal RGB Decimal
%x<255 153 153>      [ansi(<255 153 153>,TEXT)] %x<255 255 153>      [ansi(<255 255 153>,TEXT)]
%x<255 153 255>      [ansi(<255 153 255>,TEXT)] %x<153 255 204>      [ansi(<153 255 204>,TEXT)]
%x<204 153 255>      [ansi(<204 153 255>,TEXT)] %x<153 204 255>      [ansi(<153 204 255>,TEXT)]

RGB Decimal backgrounds with ANSI Black text:

RGB Decimal RGB Decimal
%X<255 153 153>      [ansi(x/<255 153 153>,TEXT)] %X<255 255 153>      [ansi(x/<255 255 153>,TEXT)]
%X<255 153 255>      [ansi(x/<255 153 255>,TEXT)] %X<153 255 204>      [ansi(x/<153 255 204>,TEXT)]
%X<204 153 255>      [ansi(x/<204 153 255>,TEXT)] %X<153 204 255>      [ansi(x/<153 204 255>,TEXT)]



Highlighting and Underline

Highlighting and underlining both require you to set the "null" marker to clear them.

To show by example:

Copy and paste the following into your game client. The 'think' command is like paging yourself. No one else will see it.

think %xh%xrBRIGHT RED NOT-DARK RED%xn
think %xh%xrBRIGHT RED%xn %xrDARK RED%xn

See the %xn in the second one?

That's the null marker. It kills both the h and the r. Then, you set a new r.

One advantage of using ansi() over %x substitutions is that ansi() does the null automatically.

The same results would be achieved by...

think ansi(hr,BRIGHT RED NOT DARK RED)
think ansi(hr,BRIGHT RED,r,%bDARK RED)

As you can see, however, I needed to add a %b between the text in there -- %b stands for 'space' substitution-wise. It's like %r (return) and %t (tab).

Without the %b, it shows up as BRIGHT REDDARK RED.

Flashing & Inverse

These are seldom used, but operate the same way as highlighting and underlining.

Flashing, especially, is considered an obnoxious terrible awful thing, since it makes text flash on the screen in a rapid flicker.

Using Multiple Colours In One Word

Let's say I want to do a rainbow of regular ANSI (for ease of reading this example -- it would work with HTML/RGB too).

I want Red, Yellow, Green, Cyan, Blue, Magenta, Red for my colours.

Text: R A I N B O W
ANSI: r y g c b m r

I could use substitutions...

think %xrR%xyA%xgI%xcN%xbB%xmO%xrW%xn

Or I could use ansi()...

think ansi(r,R,y,A,g,I,c,N,b,B,m,O,r,W)

Using Highlight AND Multiple Colours In One Word

What if I want to have those colours highlighted? Here's a case where substitutions are much more efficient.

See, if I'm using substitutions, all I need is a single %xh in front of all that text above.

think %xh%xrR%xyA%xgI%xcN%xbB%xmO%xrW%xn

But if I use ansi(), I need to put an h in front of every single colour code in the function:

think ansi(hr,R,hy,A,hg,I,hc,N,hb,B,hm,O,hr,W)

On the other hand, the ansi() makes life a bit easier to deal with when you want to highlight only SPECIFIC letters of a word...

Let's say I have my RAINBOW, and I want to make every other letter highlighted. That'd be a bright red R, a bright green I, a bright blue B and a bright red W.

Using substitutions, I'm going to need to slip in %xn after every highlighted letter, because if I don't... well. Here's an example of what NOT to do:

 think %xh%xrR%xyA%xh%xgI%xcN%xh%xbB%xmO%xh%xrW%xn

It all came out bright, right? That's because you never told it to stop highlighting.

Howeeeever...

 think %xh%xrR%xn%xyA%xh%xgI%xn%xcN%xh%xbB%xn%xmO%xh%xrW%xn

This one works, because we stop the highlight after each highlighted letter.

Now, that's getting awfully long, and it's hard to read. All the %xn thrown in there doesn't help. Using ansi(), in this case, really is easier. See, because it does an auto-%xn after every letter, you don't NEED to write them in.

You just highlight the ones you want.

think ansi(hr,R,y,A,hg,I,c,N,hb,B,m,O,hr,W)

This same principle works for underline, flashing and inverse.

Using Coloured Words Amidst UN-Coloured Text

Here's where that %xn gets even more critical, and where you need to learn a bit about code if you want to use ansi() instead.

Let's keep it simple. I'm going to use basic ANSI 16, and only one colour: red (r).

The following rules do also apply when using with HTML and RGB, however. They just get messier to read.

Substitutions

You want to write a sentence:

The apple is red and delicious.

You know you can use %xh%xrred%xn to make the word red, well, red.

Problem being, if you don't use %xn...

The apple is red and delicious.

...everything after it gets red, too.

The correct way of using ANSI substitutions amidst uncoloured text is to always place a %xn at the end of the text you want coloured.

The apple is %xh%xrred%xn and delicious.

ANSI() Function

You want to write the same sentence using ansi() instead:

The apple is red and delicious.

You know you can use ansi(hr,red) to make the word bright red.

However, functions can't readily be picked out from the rest of your sentence, unlike substitutions.

think The apple is ansi(hr,red) and delicious.

Doesn't make it red, does it? It just shows 'The apple is ansi(hr,red) and delicious.'

See, there are certain special characters the game always keeps a sharp eye out for. The % is one of them, which is why you keep ending up with 'I agree 100 dude!' instead of 'I agree 100% dude!' when paging friends -- the % gets eaten (parsed) by the system, trying to identify whether or not what you just said was supposed to be some form of code.

The character WE want right now is [. [ and ], technically (square brackets).

When using a function amidst other text, ALWAYS enclose it within square brackets.

The correct version of our sentence would, consequently, look like this:

think The apple is [ansi(hr,red)] and delicious.