Difference between revisions of "ShowMessage"
imported>JT |
imported>Cipscis (Updated to use function template) |
||
Line 1: | Line 1: | ||
== | {{Function | ||
|origin = GECK1 | |||
|summary = [[ShowMessage]] is used to display [[message|messages]] to the player. The message itself is an editor object that contains all the data: display text, type of message, and buttons (if the message is a message box). | |||
|arguments = {{FunctionArgument | |||
|Name = MessageID | |||
|Type = ref | |||
}}{{FunctionArgument | |||
|Name = var1 | |||
|Type = var | |||
}}{{FunctionArgument | |||
|Name = var2 | |||
|Type = var | |||
}}{{FunctionArgument | |||
|Name = ... | |||
}}{{FunctionArgument | |||
|Name = var9 | |||
|Type = var | |||
}}{{FunctionArgument | |||
|Name = Duration | |||
|Type = int | |||
|Optional = true | |||
}} | |||
The number of ''var'' parameters required is equal to the number of [[ShowMessage#Formatting_messages|format specifiers]] in the specified message's content, up to a maximum of 9. | |||
|example = ShowMessage MyMessage | |||
Shows ''MyMessage''. | |||
ShowMessage TimeScaleMessage TimeScale | |||
Shows ''TimeScaleMessage'', and inserts the value stored in ''TimeScale'' into it. In order for this to work, ''TimeScaleMessage'' must have the appropriate [[ShowMessage#Formatting_messages|format specifier]] to display a floating point value. | |||
}} | |||
== | ==Notes== | ||
* This command replaces the "Message" and "MessageBox" functions of Oblivion and Morrowind. | * This command replaces the "Message" and "MessageBox" functions of Oblivion and Morrowind. | ||
* Buttons are part of the Message form. If no buttons are specified on a MessageBox type message, a default "OK" button will be displayed. | * Buttons are part of the Message form. If no buttons are specified on a MessageBox type message, a default "OK" button will be displayed. | ||
Line 12: | Line 35: | ||
* Variables can be inserted into the displayed text (see below). The message will fail to display if the wrong number of variables are passed into the ShowMessage call. | * Variables can be inserted into the displayed text (see below). The message will fail to display if the wrong number of variables are passed into the ShowMessage call. | ||
* Variables cannot be inserted into a message box's buttons. | * Variables cannot be inserted into a message box's buttons. | ||
* The " | * The "Duration" parameter doesn't actually do anything | ||
== | ==Formatting messages== | ||
Variable parameters can be used in conjunction with a Message in order to insert variables into the displayed text. | Variable parameters can be used in conjunction with a Message in order to insert variables into the displayed text. | ||
* Use the formatting notation below in the text of the Message. | * Use the formatting notation below in the text of the Message. |
Revision as of 21:08, 29 March 2010
A function included in the GECK version 1.1.0.36.
Description
ShowMessage is used to display messages to the player. The message itself is an editor object that contains all the data: display text, type of message, and buttons (if the message is a message box).
Syntax
ShowMessage MessageID:ref var1:var var2:var ... var9:var Duration:int
The number of var parameters required is equal to the number of format specifiers in the specified message's content, up to a maximum of 9.
Example
ShowMessage MyMessage
Shows MyMessage.
ShowMessage TimeScaleMessage TimeScale
Shows TimeScaleMessage, and inserts the value stored in TimeScale into it. In order for this to work, TimeScaleMessage must have the appropriate format specifier to display a floating point value.
Notes
- This command replaces the "Message" and "MessageBox" functions of Oblivion and Morrowind.
- Buttons are part of the Message form. If no buttons are specified on a MessageBox type message, a default "OK" button will be displayed.
- Message Type on the Message determines whether we are displaying a "message" (upper right corner, single line of text, doesn't interrupt the game) or a "message box" (center of the screen, game stops until the player presses one of the buttons).
- The optional parameters must be declared variables or globals. You cannot use constant values.
- Variables can be inserted into the displayed text (see below). The message will fail to display if the wrong number of variables are passed into the ShowMessage call.
- Variables cannot be inserted into a message box's buttons.
- The "Duration" parameter doesn't actually do anything
Formatting messages
Variable parameters can be used in conjunction with a Message in order to insert variables into the displayed text.
- Use the formatting notation below in the text of the Message.
- The number of parameters called by ShowMessage must match the number of variables the message is expecting.
Formatting notation
%.2f - This means format the variable with 2 decimal places.
%.0f - This will format the variable with 0 decimal places, so is the normal choice for integers.
%5.0f - The number in front of the point specifies the minimum width of the number. In this case, there will always be enough space in front of the number for 5 digits:
Number 12 wins Number 1234 wins
Formatting switches
The following formatting switches can be used in Messages. Put them in any sequence right after the '%'
Switch | Function |
---|---|
+ | Display + in front of positive numbers |
<Space> | Leave a leading space in front of positive numbers |
- | Use left-aligned formation instead of right alligned. |
0 | The filling-char used for formatting is '0' instead of ' ' |
Other Functions
%g - This usually works just like "%.0f", displaying 0 decimal places. When the number is 1000000 or larger, though, the game diplays it in scientific notation (1E+006)
%.3e - Shows numbers in scientific notation (123000 = 1.23E+005)
%% - Use this to display a percent-sign in the message
&sUActn... - Allows you to insert the key used for a given control, such as the Activate button, the Always Run button, or the Block button. See the sUActn article for the list of control codes.