MessageBoxEx
From The Elder Scrolls Construction Set Wiki
A command for Oblivion Script Extender
Syntax:
(nothing) MessageBoxEX "formatString:string" var1 var2 ... var20
Displays a formatted MessageBox using the extended format specifiers. Format specifiers may appear within buttons. Button text should be included within the format string, separated by the pipe character |.
- You can use up to 10 buttons
- You can use up to 20 variables
Example
Note that due to wiki limitations, the MessageboxEX line has been split into two
ref refVar1
ref refVar2
short keyCode
short goldCost
...
set refVar1 to AdrianDecanusREF
set refVar2 to ShadySamREF
set keyCode to GetControl 15 ; menu key, assuming 'Tab' (15)
set goldCost to 500
MessageBoxEX "Press %k to summon a companion %rCost: %g gold|%n|%n|Cancel"
keyCode goldCost refVar1 refVar2
prints out
Press TAB to summon a companion
Cost: 500 gold
[Adrian Decanus]
[Shady Sam]
[Cancel]
[edit] Notes
- For info on how to create working menus see MessageBox Tutorial.
- When creating menus for mods it can be helpful to standardize how information and choices are displayed. See Standard Menu UI for some helpful suggestions.
- Displays a maximum of 512 characters.
- As of v0014a, increased to 4096 characters
- Multiple MessageBoxes or MessageBoxExes may cause GetButtonPressed to return an incorrect value.
- Fixed as of v0014a
- Switched Text ("On/Off", "Enabled/Disabled", "Alpha/Beta/Gamma")
- If you would like to use different strings based on a boolean or integer parameter, you can use the %c format with a dummy spell or faction.
- E.g. Ninja Ranks
- Create "NinjaRanksSpell" spell and add script effects with the effect names: Student, Genin, Chuunin, Jonin, Hokage.
ref NinjaRanksRef
...
set NinjaRanksRef to NinjaRanksSpell
MBoxEx "You're not ready to be a %c level ninja!" NinjaRanksRef iNextNinjaLevel
- Factions or spells with named script effects can both be used. Factions are easier to set up in game, spells allow dynamic control over the text via the magic functions that modify spell effect lists.
- Note: Be sure that index is within range of defined ranks. I.e. if you have defined two ranks for a boolean value, make sure that the index is really limited to 0 or 1. (Otherwise, CTD!)
- Reference variables must be local variables declared in the same script. Syntaxes like 'someRef.var' or 'someQuest.var' work for numeric arguments only.
- Doesn't seem to work with Oblivion version 1.1 - GetButtonPressed never returns the correct value. May be limited to an object script, or even an activator, etc. but be aware.
[edit] Displaying Variables
[edit] 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
[edit] Formating switches
The following formatting switches can be used in Oblivion. 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 ' ' |
[edit] 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
[edit] OBSE Format Specifiers
In addition to the format specifiers supported by Oblivion's Message and MessageBox functions, OBSE functions understand additional specifiers.
%r - Prints a carriage return, ending the current line and starting at the next.
%n - Prints the name of the specified reference or object.
- In OBSE versions prior to v0014a, %n can crash if the object's name contains a percent sign.
%i - Prints the formID of the specified reference or object.
%k - Prints the name of the key for the specified DirectInput scancode, such as those used for IsKeyPressed2.
%c - Prints the specified component of the specified reference or object. Takes two arguments - a reference variable set to the spell or faction, and an index. Behaves differently depending on the passed reference:
- Faction: Prints the nth male rank title
- Magic Item: Prints the nth Magic Effect
- Prior to OBSE v0015, magic effects using actor values (such as Restore Agility) would not display the specific actor value.
- Actor values may not display correctly for non-English versions of Oblivion.
%p - Displays a pronoun based on the gender of the object parameter:
- %po - objective (him, her, it)
- %pp - possessive (his, her, its)
- %ps - subjective (he, she, it)
%q - Prints a double quote character.
%a - Prints the character corresponding to the specified ASCII code. Passing codes for unprintable characters (such as 0) may have unpredictable (though occassionally) useful results. Passing the code for a percent sign will most likely crash the game as literal percent signs must come in pairs.
%v - Prints the actor value (i.e. an attribute or skill) associated with the passed actor value code.
%e - Provides a workaround for the script compiler's refusal to accept an empty string as a command argument.
- Example:
SetNameEx "" object ; attempts to remove an object's name, but won't compile SetNameEx "%e" object ; sets the name to an empty string
%{...%} - Conditionally displays or omits the bracketed portion of the format string based on a boolean value. Accepts a variable - if the value of the variable is zero, all text and parameters up to the matching right bracket will be ignored. Otherwise the bracketed text will be displayed.
- Example (should be single-line, line-breaks added for Wiki)
MBoxEX "Doom comes%{ for you%}. What will you do?
|Dig a hole, hide
%{|Find someone, offer as sacrifice|Find someone, use as shield%}
|Enjoy your final 15 minutes" bDisplay bDisplay
If bDisplay is 0 this will print out
Doom comes. What will you do? [Dig a hole, hide] [Enjoy your final 15 minutes]
If bDisplay is 1 this will print out
Doom comes for you. What will you do? [Dig a hole, hide] [Find someone, offer as sacrifice] [Find someone, use as shield] [Enjoy your final 15 minutes]
- Note: When using GetButtonPressed with messageboxes that can have a avariable number of buttons displayed using %{...%}, the return value will be relative to the actual number of buttons displayed and will not include buttons hidden by %{...%}.

