/ \      _             Play Now                         Nemesis on fb
          | |     | |  _______   _        _   _______    _______   _    _______
          | |\    | | |   ____| |  \    /  | |   ____|  /   ____| | |  /   ____|
O= Home <=XX|  About  News  Pics  Adventurers  Wizards  Download  Connect     >
          | |   \   | |  |____  | |      | | |  |____   ___ \  \  | |  ___ \  \
          | |     \_| |_______| |_|      |_| |_______| |_______/  |_| |_______/
          \ /

Documentation Area

Document Path: /doc/lib/curse_string

Simul efun: curse_string - colour a string

	string curse_string(string replace, object player, status ignore_end)

	This function helps you to use ANSI-colours. It also checks if the
	player should get the codes, that means it checks the settings.

	DO NOT use ANSI escape sequences directly! See Note: below.

	The first argument is a string with codes starting with a dollar-sign
	('$'), a bit like (s)printf() or format_date(). Valid interpreted
	sequences are:

	$$	a literal '$'
	$b	bold
	$u	underlined
	$f	flashing/blinking
	$i	inverse
		background colour
		foreground colour
	$a	alert colour (set by player)
	$e	exit colour (set by player)
	$n	back to normal
	<colour-char> can be the following:
	B	black
	r	red
	g	green
	y	yellow (on some terminals brown)
	b	blue
	p	purple
	c	cyan
	w	white (on some terminals light grey)

	The optional second argument is the living which will be asked for
	settings. NPCs get no ANSI-codes. The default is this_player().

	If the optional third argument is zero (default), the function checks
	if you forgot to set back to normal. You can turn this feature off,
	for example if you need an ANSI-code more than once and with different
	text in it, by passing a non-zero third argument.

Return value:
	The replaced string with ANSI-codes.

	write(curse_string("There are some $Cggreen leaves$n on the $CBdark "+
	"There are some", "on the" and the "." at the end will be normal,
	"green leaves" will be green and "dark branch" will be black.

	write(curse_string("$aThe sand in your hourglass has run out "+
	The full message will be in alert colour.

	Please don't use colours too often and only if it makes sense, for
	example in ASCII-art.

	Please don't '#include <ansi.h>' and do not use the '#defines' of
	ANSI-codes directly! ALWAYS use the simulated efun curse_string!

See also:

This page was generated in LPC

Imprint / Impressum