From ZDoom Wiki
Jump to: navigation, search

void Print(item(s));


Print will print something to the activating player's screen. This can be text or variables or any combination of the two. Note that Print is fairly inflexible (there is no way to modify the position on screen or the time the message stays up) so you may wish to consider using HudMessage instead.

Print will only display for the activator of the script, so if another player activates a script with a Print statement in it, then it will only be displayed for that other player and you will not see it. For printing to all players, see PrintBold. If a script is activated by something that is not a player at all then the message will simply not be displayed anywhere.

Note: Do not use Print as a debug tool. In many scripting and programming languages it is quite common to check that a complex code executes properly by MiniWikipediaLogoIcon.pngtracing its operation with print or prints statements; in ACS, you need to use Log or PrintBold or the trace will possibly not display at all, making it look like the script does not actually run.

Cast type

Item syntax
<cast type>:<expression>

The string can be built up of any number of these items, separated by commas. The cast type is used to differentiate what type of data is being displayed. The table below shows the available options.

cast type description
a prints a character array. (Ex.: a:arrayname)

a:(arrayname[, int starting_index[, int size_limit]]) prints the character array specified by arrayname starting from starting_index, printing only up to size_limit characters.

b binary number
c character
d decimal number (integer, same as i)
f fixed point number
i decimal number (integer, same as d)
k prints the key(s) (up to 2) that the player has bound to the specified command. (Ex.: k:"+use")
l localized string from LANGUAGE
n name, expression could be:
  • PRINTNAME_LEVELNAME - Prints the level name (e.g., "Entryway").
  • PRINTNAME_LEVEL - Prints the map lump name (e.g., "MAP01").
  • PRINTNAME_SKILL - Prints the skill name (e.g., "Hurt me plenty").
  • PRINTNAME_NEXTLEVEL - Prints the map lump name of the next map. (New from 2.4.0)
  • PRINTNAME_NEXTSECRET - Prints the map lump name of the next secret map. (New from 2.4.0)

Using 0 as expression prints the name of the activator (a tag name if the activator isn't a player, player name otherwise). Values greater than 0 will print the name of the n-th player (one-based).

s string
x hexadecimal number

Escape sequence

The other special characters to note are escaped characters. A new line is started with \n. A backslash character is placed with \\, except there is no graphic for backslash by default in Doom.

Escape sequences are contained within a string. They begin with the backslash character: '\'.

Available escape sequences, as handled by the strbin function in cmdlib.cpp, include:

sequence description
\OOO Inserts a character by the octal value of its ASCII code. OOO must be a valid three-digit octal number.
\a Beep(Verification needed)
\b Backspace (erases previous character)(Verification needed)
\cCODE Beginning of a color escape sequence, see below for color codes.
\f Clear string buffer(Verification needed)
\n New line
\r New line (Advisable to use \n)(Verification needed)
\t Tabulation
\v Vertical tabulation(Verification needed)
\xXX Inserts a character by the hexadecimal value of its ASCII code. XX must be a valid two-digit hexadecimal number.
\? Delete (erases next character)(Verification needed)
\↵ Ignore the "new line" separator. This can be used to split a long string on several lines in the script source code. Make sure there aren't any space or other invisible character after the backslash and before the end of the line, however.


You can add color to lines of text by using the \cX escape code. Replace X with the following letter to produce the desired color:

code color code color
a ██ reddish brick l use original colors
b ██ tan m ██ black
c ██ gray n ██ light blue
d ██ green o ██ cream
e ██ brown p ██ olive
f ██ gold q ██ dark green
g ██ red r ██ dark red
h ██ blue s ██ dark brown
i ██ orange t ██ purple
j ██ white u ██ dark gray
k ██ yellow v ██ cyan
- Default color for Print messages * Default color for chat messages
+ Default color for PrintBold messages ! Default color for team chat messages

The color will revert back to the default message color at the end of every line, therefore a \cX escape must be on every line where color is needed. Using \c- also clears color, so that printed messages (obituaries, pickup messages, etc.) with player names within them will retain their individual colors.

For example,

print(s:"\cgRoses are red\n\chViolets are blue\n\cjSilver for me\n\cfGold for you");

will be displayed as Printcolor.png.

You can also use the syntax \c[colorname], where colorname is a name of a color as defined in the textcolors lump.

For example,

print(s:"\c[Green]This is green");

Would print

This is green


Some basic uses of print.

script 1 (void)
	int x = 10;
	Print(s:"This is a string");   //prints "This is a string"
	Print(d:x);   //prints "10"
	Print(s:"This is x: ", d:x);   //prints "This is x: 10"
	Print(s:"I need ", d:x, s:" shells");   //prints "I need 10 shells"

Another example of a (potentially) useful debugging script which continually updates the player on their current game coordinates:

script 1 ENTER
		Print(f:GetActorX(0), s:" : ",

This example tells the user to press whatever key they have bound to +use:

script 1 (void)
       Print(s:"Press ", k:"+use", s:" to use this ladder.");