CustomMessage
Category: Messages
Since engine version: 4.9.6.0 CR
Description
Prints a message.
Syntax
bool CustomMessage
(string message, object obj, int plr, int offset_x, int offset_y, int color, id deco, string portrait, int flags, int iHSize);
Parameters
- message:
Message to be displayed.
- obj:
[opt]
If not nil the message will be shown above the specified object.
- plr:
Player number for whom the message should be visible. If NO_OWNER is specified the message will be shown for all players.
- offset_x:
[opt]
x-offset of the message position. For global messages, it is the viewport center. For object messages it relative to the default message position above the object. For portrait messages (portrait!=0) it is the offset relative to the upper left viewport corner.
- offset_y:
[opt]
y-offset of the message position.
- color:
[opt]
Color of the message. 0 means default of 0xffffff (white).
- deco:
[opt]
ID for the message decoration. If set a frame will be drawn around the message. Only valid when a portrait is specified.
- portrait:
[opt]
Image specification for a picture left of the message inside the frame.
- flags:
[opt]
Bit mask composed of additional settings. Possible values:
Bit |
Constant |
Description |
0 |
MSG_NoBreak |
If set no automatic line breaks are made. |
1 |
MSG_Bottom |
Only for global messages. For portrait messages with decoration frame: The position offset is relative to the bottom viewport edge instead f the top. For non-portrait messages the position is only shifted a bit downwards. |
2 |
MSG_Multiple |
If set previous messages of the same type aren't removed. |
3 |
MSG_Top |
Only for global messages. For portrait messages with decoration frame: The position offset is relative to the top viewport edge. For non-portrait messages the position is only shifted a bit upwards. |
4 |
MSG_Left |
Only for global messages. For portrait messages with decoration frame: The position offset is relative to the left viewport edge. For non-portrait messages the position is only shifted a bit to the left. |
5 |
MSG_Right |
Only for global messages. For portrait messages with decoration frame: The position offset is relative to the right viewport edge. For non-portrait messages the position is only shifted a bit to the right. |
6 |
MSG_HCenter |
Only for global messages. The message is centered horizontally. |
7 |
MSG_VCenter |
Only for global messages. The message is centered vertically. |
8 |
MSG_DropSpeech |
The message is truncated at the first occurrence of '$'. |
9 |
MSG_WidthRel |
iHSize specifies the text width in percent relative to the viewport width. Only for global and player messages. |
10 |
MSG_XRel |
offset_x specifies the x-offset in percent relative to the viewport width. Only for global and player messages. Recommended values: -50 to +50. |
11 |
MSG_YRel |
offset_y specifies the y-offset in percent relative to the viewport height. Only for global and player messages. Recommended values: -70 to +25. |
- iHSize:
[opt]
Text width in pixels.
Remarks
This function combines the functionality of
Message,
PlrMessage and
PlayerMessage and also gives extended control over the message. For future extendability without needing to create a totally new function it intendedly doesn't have builtin formatting support. Formatting can be done via explicitly using
Format.
The message text may include formatting modifications as usual. Messages starting with '@' don't disappear automatically. "|" represents a line break. The italic tag <i> and the color tag <c> are supported as usual.
Essentially, messages are displayed until a timeout depending on the message length is over or the message is replaced by another one of the same class. A global message (i.e. obj = nil) replaces all previous global messages, and object messages (obj != nil) replaces all other object messages of the same object. For displaying multiple messages of the same class MSG_Multiple may be used.
Examples
CustomMessage("This is <i>madness</i>!");
Displays the message "This is madness!" visible only for player 0. The word "madness" is italicized.
CustomMessage("<c ffff00>Tonki:</c> Hello, world", 0, NO_OWNER, 100,100, 0, MD69, "Portrait:CLNK::00ff00::1);"
Displays a message with decoration frame. The name Tonki is displayed in yellow. Left of the message a green Clonk portrait is shown. The decoration definition MD69 must be loaded.
Sven2, Juli 2008