Simulate color

Posted by Renz on Fri 10 Jul 2009 08:21 AM — 4 posts, 19,811 views.

#0
How do I use Simulate in Lua to output coloured text? Also, can it output italicized or bolded text?
Australia Forum Administrator #1
Don't use Simulate, use AnsiNote:

http://www.gammon.com.au/scripts/doc.php?function=AnsiNote

And for just coloured output, the easiest is ColourNote, which lets you use any RGB colour, not just the 16 ANSI ones.

http://www.gammon.com.au/scripts/doc.php?function=ColourNote
Amended on Fri 10 Jul 2009 08:42 AM by Nick Gammon
Australia #2
This is a bit of a late reply, but I was just wondering how to do this myself.

If you're using Simulate() to test triggers rather than add a note (for which, like Nick said, it's easier to use a note function), you can insert ANSI sequences to add colour and other ANSI-ish-things. This is very useful when testing colour triggers.

The easiest way to insert ANSI sequences in MUSHclient is to use its ANSI() function. For instance, to test bold green text:
Simulate (ANSI(1,32) .. "Hello!  I'm bold green.\n" .. ANSI(0))


See http://www.gammon.com.au/scripts/doc.php?function=ANSI for for more information and the ANSI colour codes.
Amended on Sat 25 Jul 2009 05:29 AM by Teapot
Australia Forum Administrator #3
Quote:

Also, can it output italicized or bolded text?


In my earlier reply I had forgotten about NoteStyle - this lets you do italic, bold, inverse and underlined text for the next note (until the end of the current line).

http://www.gammon.com.au/scripts/doc.php?function=NoteStyle

You are right, Simulate is appropriate for testing triggers (or you can use the Game menu -> Test Trigger dialog).

To simply display coloured text (eg. in a trigger) it is better to use ColourNote, Note, ColourTell, in conjunction with NoteStyle if required.