game_text
Class hierarchy |
---|
CGameText |
maprules.cpp
|
game_text
is a point entity available in all Source games except Left 4 Dead 2.[1]
This entity displays text on player's screens. This text can be defined directly in the Hammer editor (unlike the similar env_message
entity, which uses the titles.txt
file[confirm]). In multiplayer games, the text will normally only display for the activator of the "Display" input. The "All Players" flag can be ticked in order to display on the screens of all players.
titles.txt
script for text parameters instead of keyvalues, allowing the text to be changed without having to recompile any maps. It also supports newlines and quotation marks, unlike regular game_text
.game_text
supports localized strings (e.g., #HL2_Chapter4_Title) in most or all Source games.Caveats
Game_text
works as a HUD element, specifically, a HudMessage
element, defined in /scripts/HudLayout.txt
.
Because it was created aiming at low-resolution monitors (owing to Source's age), it is by default restricted to scaling based on 640x480 resolution.
This causes it to scale incorrectly at resolutions higher than 1920x1080. Text will be much larger and some text will be hidden.
It also causes it to only use a limited region of the screen for drawing, and long lines of text, or text near the edges, get cropped on widescreen. This affects other text that uses HudMessage
, such as the infamous "A. I. Disabled" message.
/scripts/HudLayout.txt
and find the section "HudMessage". Change its "wide"
and "tall"
values (default: 640 and 480) to "f0" (full size of the viewport). This will increase the maximum size of the invisible VGUI screen that text appears on, making it scale above 1920x1080 resolutions.[Tested on 2k, 4k, and ultrawide resolutions. Does this work on all resolutions?]Flags
All Players : [1]
- If this is not set, the message will only show to
!activator
.
Keyvalues
- Name
(targetname)
<string> - The name that other entities refer to this entity by, via Inputs/Outputs or other keyvalues (e.g.
parentname
ortarget
).
Also displayed in Hammer's 2D views and Entity Report.See also: Generic Keyvalues, Inputs and Outputs available to all entities
- Message Text
(message)
<string> - Message to display onscreen. \n signifies a new line in the text.
- Bug:Hammer will automatically change backslashes to forward slashes, making \n impossible to enter.Workaround:
- Edit the VMF with a text editor, although this will need to be reapplied after each save
- Edit the BSP entity lump with a hex editor, although this will need to be reapplied after each compile
- Use AddOutput to set the message, as outputs are not affected
Tip: Hammer++ does not do this.[todo tested in?] - X (0 - 1.0 = left to right) (-1 centers)
(x)
<string> - Horizontal position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the far left of the screen and 1 is the far right. -1 centers the text.
- Y (0 - 1.0 = top to bottom) (-1 centers)
(y)
<string> - Vertical position on the player's screens to draw the text. The value should be between 0 and 1, where 0 is the top of the screen and 1 is the bottom. -1 centers the text.
- Text Effect
(effect)
<choices> - Text scan effect
- 0: Fade In/Out. The whole text is faded in, and then faded out.
- 1: Credits Todo: Unknown—seems to act like Fade In/Out. Provide description.
- 2: Scan Out. The text is scanned in letter by letter, and the whole text is then faded out.
- Color1
(color)
<color255> - The primary color used by all the text effects. Note:The color values seem to be added to the background, so either a bright white background or black text will cause the message to be invisible.Note:This keyvalue will default to black for entities not created in Hammer.
- Color2
(color2)
<color255> - The scanning color for the letter being scanned if the Text Effect keyvalue is set to Scan Out—usually a different shade of Color1.
- Fade in Time (or character scan time)
(fadein)
<string> - The time it should take for the text to fully fade in.
- Fade Out Time
(fadeout)
<string> - The time it should take for the text to fade out, after the hold time has expired.
- Hold Time
(holdtime)
<string> - The time the text should stay onscreen, after fading in, before it begins to fade out.Note:This value defaults to zero for entities not created in Hammer.
- Scan time (scan effect only)
(fxtime)
<string> - If the 'Text Effect' is set to Scan Out, this is the time it should take to scan out all the letters in the text.
- Text Channel
(channel)
<choices> - You can have up to six individual game_text messages onscreen at once, stored in channels. Select which channel this text should be placed in, which will overwrite any active message already in that channel.
- Master
(master)
<string> - Legacy support: The name of a master entity. If the master hasn't been activated, this entity will not activate.
Inputs
Display
- Display the message text.Note:If the All Players flag is not set, the player must be the
!activator
of this input in order for the text to be shown.
SetText
<string> (in all games since )- Set the text to display.
AddOutput message
can be used to change text at runtime in older games which do not support SetText, although the Display
input must be fired again.SetPosX
<float> (in all games since )- Set the X position of the text. (0 - 1.0 = left to right) (-1 centers)
SetPosY
<float> (in all games since )- Set the Y position of the text. (0 - 1.0 = top to bottom) (-1 centers)
SetTextColor
<color255> (in all games since )- Set color of the front text.
SetTextColor2
<color255> (in all games since )- Set color of the transition text.
See also
game_text_tf
- Displays a custom HUD message with icons on a specified team's screen.point_worldtext
- A similar entity that displays a custom message in the world with far more flexibility.training_annotation
- A similar entity that points to a specified location in the world.env_hudhint
- Displays a custom HUD message. Commonly used to show key-binds.env_message
- Displays a pre-defined message on the players screen.point_message
- A similar entity that displays a small custom message at a specific position in the game world.- Customizable triggered HUD-message - How to create a new entity that is similar to game_text but can receive the message string via a triggered input.