Show - Message

From the CreationKit Wiki
Jump to navigation Jump to search

Member of: Message Script

Displays the message to the screen, substituting the passed-in numbers into the appropriate spots in the text. If the message is set to display in a message box, the function waits for the user to press a button and returns which button they hit.

Syntax[edit | edit source]

int Function Show(float afArg1 = 0.0, float afArg2 = 0.0, float afArg3 = 0.0, float afArg4 = 0.0, float afArg5 = 0.0,
    float afArg6 = 0.0, float afArg7 = 0.0, float afArg8 = 0.0, float afArg9 = 0.0) native

Parameters[edit | edit source]

  • afArg1: The number to substitute into the first spot in the text.
    • Default: 0.0
  • afArg2: The number to substitute into the second spot in the text.
    • Default: 0.0
  • afArg3: The number to substitute into the third spot in the text.
    • Default: 0.0
  • afArg4: The number to substitute into the fourth spot in the text.
    • Default: 0.0
  • afArg5: The number to substitute into the fifth spot in the text.
    • Default: 0.0
  • afArg6: The number to substitute into the sixth spot in the text.
    • Default: 0.0
  • afArg7: The number to substitute into the seventh spot in the text.
    • Default: 0.0
  • afArg8: The number to substitute into the eighth spot in the text.
    • Default: 0.0
  • afArg9: The number to substitute into the ninth spot in the text.
    • Default: 0.0

Return Value[edit | edit source]

For a message with the message box option and buttons defined:

  • returns 0, 1, 2, ..., 9 matching the button the user hit

For a message with the message box option but no buttons defined:

  • returns 0 when the OK button is hit (a default OK button is shown on the message box)

If the message box option is not checked:

  • returns -1 immediately (and the message is shown as a notification)

When called on a property or variable that isn't filled correctly:

  • returns 0 immediately (and nothing is shown)

Examples[edit | edit source]

; Display a simple message to the user
HelloWorld.Show()


; Display a message, replacing the first number with a 10
YouGotGold.Show(10.0)


;/ Display a message, replacing the second number with a 10, the third number with a 20 (leaving first 0), and getting
   the button the user hit /;
int ibutton = YetAnotherMessage.Show(0.0, 10.0, 20.0)

Using the above example, you could show a message box whose text is "You've collected %.0f apples and %.0f oranges. You now have %.0f fruits total." This would result in the displayed text "You've collected 0 apples and 10 oranges. You now have 20 fruits total."

Notes[edit | edit source]

To designate where to put the numbers in the message in the editor, the following format is used:

%[flags][width][.precision]f

If you want the message to contain a % sign, then you must use a double % sign like so:

%%

These arguments do not appear to work on buttons.

Flags[edit | edit source]

Flags is one or more of the following characters:

Character Meaning Default
- Left-align the number Right-align the number
+ Prefix the number with a + or - sign Prefix only negative numbers with a - sign
0 If width is prefixed with a 0, 0s are added until the minimum width is reached. If both 0 and – flags appear, the 0 is ignored. No padding is used
<Space> Prefix the value with a space if the output value is signed and positive. This flag is ignored if both the space and + flags appear. No space appears
# Forces the number to have a decimal point. Decimal point appears only if numbers follow it.

Width[edit | edit source]

This is an optional number that specifies the minimum number of characters to output. This includes the sign character (+ or -) and the decimal point, if any.

Precision[edit | edit source]

This value specifies the number of digits after the decimal point. If a decimal point appears, there is always at least one digit before it. The value is rounded to the appropriate number of digits.

The default precision is 6. If precision is 0, or if the period appears without a number following it, no decimal point is printed.

Examples[edit | edit source]

Values:

5
1.1
-0.523456745

"%f" results in:

5.0
1.1
-0.523457

"%.0f" results in:

5
1
-1

"%+05f" results in:

+0005
+01.1
-0.523457

"%10.2f" results in:

      5.00
      1.10
     -0.52

See Also[edit | edit source]