Vlatitude: Onscreen Messages Last edited 6 months ago2019-04-25 11:34:05 UTC by Penguinboy Penguinboy

Download example

Making a message appear onscreen is an easy task. With Half-Life version 1.0.0.9 and above, there are two ways of going about this task. The first is using the old standby entity, env_message. The second is to use the new game_text entity. We'll start with the env_message first.

Env_Message

The env_message entity is a point based entity that displays a specified message when triggered. The trigger can be a trigger_once, trigger_auto, a button, etc. In the message attribute you put the name of a message from the titles.txt file that's located in the .pak file. There is also a list of these messages in the Resources section. These are the only two attributes needed to use an env_message, Name and Message.

One of the questions frequently asked is: "How do I make my own custom messages appear?". For that we have to add to the titles.txt file. Following is an excerpt from that file.
//TITLES FOR HALF-LIFE
// Position command $position x y
// x & y are from 0 to 1 to be screen resolution independent
// -1 means center in each dimension
// Effect command $effect <effect number>
// effect 0 is fade in/fade out
// effect 1 is flickery credits
// effect 2 is write out (training room)
// Text color r g b command $color
// fadein time fadeout time / hold time
// $fadein (message fade in time - per character in effect 2)
// $fadeout (message fade out time)
// $holdtime (stay on the screen for this long)

//INTRO TITLES
// All centered for now
$position -1 -1
$effect 2
// This is the final color
$color 100 100 100
// This is the highlight color
$color2 240 110 0
// This is the time it takes to fade each character
$fadein 0.01
// This is the amount of time the highlight lags behind the leading edge of the text
$fxtime 0.25
// How long to hold the message on the screen (after it scans out)
$holdtime 3.5
// How long it takes to fade out the message after holding
$fadeout 1.5

CR27
{
Black Mesa Research Facility
Black Mesa, New Mexico
}
Right now this may all seem like gibberish to you, but we're going to take a walk though each part of this. (NOTE: Text in Italics is code for the titles.txt file)
//This is a comment
(NOTE: this only comments out one line)
$effect 0
$effect 0
TEST1
{
Sample Text 1
}

$effect 1
TEST2
{
Sample Text 2
}
Then each of the two defined messages would have different effects.
MESSAGE NAME
{
Message Text
}
There is also another, easier way to display custom messages.

Game_Text

The game_text entity was added to Half-Life with the release of version 1.0.0.9 along with some other useful entities. Like the env_message, the game_text entity needs to be triggered in order to display the text. There are many more attributes to fill in, but most of them are self-explanatory. The text you want displayed goes in the Message Text attribute. To make multi-line text you need to use the multi-line character: "\n". Here's an example: "This would be line 1\nThis would be line 2". Note that entering text longer than 127 characters can cause WorldCraft to crash. The game_text entity has made it easier for map builders to add their own text. Soon there will be a page in the Entity Barn for the game_text entity describing all of it's flags and attributes.

More on Onscreen Messages

When doing a mod it might be better to use the env_message and a custom title.txt file. Use the game_text entity for custom messages in a single map level as this saves you from having to include a new titles.txt file with your map.
This article was originally published on 69th Vlatitude.
TWHL only archives articles from defunct websites. For more information on TWHL's archiving efforts, please visit the TWHL Archiving Project page.

Comments

You must log in to post a comment. You can login or register a new account.