Morrowind Mod:MessageBox

The UESPWiki – Your source for The Elder Scrolls since 1995

MessageBox

		MessageBox, "Message", [Var1], [Var2, ...], ["button1"], ["button2"], ...

       Where:	Message      = String message to display
		Var1, 2, ... = Optional variables to insert into message
		Button1, ... = Optional button texts for displaying choices

	Type:	Misc

     Returns:	none

     Example:	

     Scripts:	

The MessageBox function has two main abilities, to display simple text messages to the player at the bottom of the screen and to display a list of choices to the player. To display a message use the function like the following:

		MessageBox, "This is a simple message"		; Simple text message
		MessageBox, "GameHour = %.2f", GameHour		; Display a float value with 2 decimal points
		MessageBox, "Long/Short = %G", 101		; Display a short/long value, not %D as in the help file!
		MessageBox, "String = %S", "SomeString"		; Display a string value, kinda useless, might not work

Use the optional variables to display numbers/strings in the message text. When displaying float values you must specify the number of decimals places to use. You can also use the %.0f format to display short/long variables. Although the help file only shows 1 or 2 optional variables, there can be more than 2.

To display a list of choices to the user, use the format:

		MessageBox, "Press ok to continue...", "Ok"		; One choice
		MessageBox, "What is your answer?", "Yes", "No"		; Two choices
		MessageBox, "Choose a number", "1", "2", "3", "4", "5"	; Five choices

There are also a number of special strings which can be used within the MessageBox string. They all begin with the ^ and not the % character as written in the help file:

		^PCName		The player's name.
		^PCClass	The player's class.
		^PCRace		The player's race.
		^PCRank		The player's rank in the speaker's faction.
		^NextPCRank	The player's next rank in the speaker's faction.
		^Cell		The cell the player is currently in.
		^Global		Any global variable value (ex: ^Day). Floats display with 1 decimal. 

To return the user's choice, use the GetButtonPressed function, for example:

begin TestMessageScript
	short MessageOn
	short Button

			; Display message when the player activates the object
	if ( OnActivate == 1 )
		set MessageOn to 1
	endif

			; Display the choices to the user
	if ( messageOn == 1 )
		MessageBox, "Do you wish to drink from the Bitter Cup or to pick it up?", "Drink", "Pick it up"
		Set messageOn to 2
	endif

	if ( messageOn == 2 )
		set Button to GetButtonPressed

		if ( Button == -1 )	; Nothing
			return;
		endif
		if ( Button == 0 )	; drink it
			Disable
			player->ModStrength, 20
			Set MessageOn to 0
			return
		endif
		if ( Button == 1 )	; pick it up
			Activate
			Set MessageOn to 0
			return
		endif
	endif
end

Use a similar setup for asking the user other choices.

If you pop up a message box with an 'ok' button when a saved game is loaded immediately after running Morrowind, you won't have a mouse pointer to click on the 'ok' button to get rid of the message box. The game also keeps running while the message box is displayed; it doesn't pause as it normally does. You can right-click to get into Menu mode, and then you'll have a mouse pointer to clear the box with. This only happens the first time you load a save after running Morrowind; if you load a save from within the game, you do get a mouse pointer to click the 'ok' button with. So apparently it's some sort of initialization problem.

See Also: GetButtonPressed