Difference between revisions of "How To ANSI"

From Fate's Harvest
Jump to: navigation, search
(Created page with "=So You Want To Play With ANSI= Promise, it isn't arcane wizardry. It's really pretty simple. To start off with, there are two types of ANSI colour codes: ANSI 16 and HTML 2...")
 
Line 1: Line 1:
 +
__NOTOC__ __NOEDITSECTION__
 
=So You Want To Play With ANSI=
 
=So You Want To Play With ANSI=
 
Promise, it isn't arcane wizardry.  It's really pretty simple.
 
Promise, it isn't arcane wizardry.  It's really pretty simple.
Line 164: Line 165:
 
   HTML and decimal-vector forms, the case of the %x or %X determines whether
 
   HTML and decimal-vector forms, the case of the %x or %X determines whether
 
   the specified color is foreground or background.
 
   the specified color is foreground or background.
 +
 +
----
 +
 +
==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.
 +
 +
==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 256 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)

Revision as of 19:48, 16 June 2017

So You Want To Play With ANSI

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

To start off with, there are two types of ANSI colour codes: ANSI 16 and HTML 256.

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.)

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
Function = those things that end in () like ansi() and do mysterious magical code stuff

For things like comtitles, it tends to be easier to use substitutions. They're quicker to type.

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.

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.

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)]
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.

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.

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 256 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)