Difference between revisions of "Options Menu"

Jump to navigation Jump to search
147 bytes added ,  19:38, 12 April 2012
m
Clarified...
imported>JustinOther
imported>JustinOther
m (Clarified...)
Line 2: Line 2:
[[Category:Papyrus]]
[[Category:Papyrus]]
== Overview ==
== Overview ==
Using [[Show - Message]], it is possible to make an options menu with any number of buttons and/or levels. This is enabling as one can maintain but a single plugin with an options menu offering multiple configuration setting rather than necessitating multiple versions. In these examples, we'll use apparel items, but a menu can be prompted and managed in a number of ways. First off, create a message(s) form and add/fill in its buttons. Note that no more than ten buttons can be offered by any given message box and that the button indices are offset by one such that the first option's index is 0 and not 1. If offering a lot of options, it's best to think ahead regarding how you want to organize your options, making the message forms first, then plugging them into the script.
Using [[Show - Message]], it is possible to make an options menu with any number of buttons and/or levels. This is enabling as one can maintain but a single plugin with an options menu offering multiple configuration setting rather than necessitating multiple versions. In these examples, we'll use apparel items, but a menu can be prompted and managed in a number of ways. First, create a message(s) form(s) and add/fill the buttons with the options you'd like to offer. Note that no more than ten buttons can be in a message box and that the button indices are offset by one such that the first option's index is 0 and not 1. If offering a lot of options, it's best to think ahead regarding how you want to organize your options, making the message forms first, then plugging them into the script.


== Examples ==
== Examples ==
*For the first example, we'll have only three options: Mage, Thief, and Warrior. The token should be unplayable in this case. When the item is added to the player, the menu will be prompted and will exit as soon as a button is selected, executing the appropriate code.
*For the first example, we'll have only three options: "Mage", "Thief", and "Warrior". The token should be unplayable in this case. When the item is added to the player, the menu will be prompted and will exit as soon as a button is selected, executing the appropriate code right after the token is silently removed.


<source lang="papyrus">ScriptName OptionsMenuScript extends ObjectReference
<source lang="papyrus">ScriptName OptionsMenuScript extends ObjectReference
Line 15: Line 15:
If akNewContainer == Game.GetPlayer() ; Only the player
If akNewContainer == Game.GetPlayer() ; Only the player
Int iButton = OptionsMESG.Show() ; Shows your menu. iButton == -1 until input
Int iButton = OptionsMESG.Show() ; Shows your menu. iButton == -1 until input
If (iButton != -1)
If (iButton != -1) ; Wait for input
akNewContainer.RemoveItem(GetBaseObject(), 1, True) ; Silently remove token
akNewContainer.RemoveItem(GetBaseObject(), 1, True) ; Silently remove token
If (iButton == 0)  ; Mage
If (iButton == 0)  ; Mage
Line 60: Line 60:
aiButton = BreakfastMESG.Show()
aiButton = BreakfastMESG.Show()
If (aiButton == 0) ; Sweet Roll
If (aiButton == 0) ; Sweet Roll
ElseIf (aiButton == 1) ; Pancakes
ElseIf (aiButton == 1) ; Pancakes, Bacon & Eggs
ElseIf (aiButton == 2) ; Bacon & Eggs
ElseIf (aiButton == 2) ; Country Fried Pony Steak
EndIf
EndIf
ElseIf (aiButton == 1) ; Lunch
ElseIf (aiButton == 1) ; Lunch
Line 67: Line 67:
If (aiButton == 0) ; Turkey Sandwich
If (aiButton == 0) ; Turkey Sandwich
ElseIf (aiButton == 1) ; Ham Sandwich
ElseIf (aiButton == 1) ; Ham Sandwich
ElseIf (aiButton == 2) ; BLT
ElseIf (aiButton == 2) ; Pony Sandwich
EndIf
EndIf
ElseIf (aiButton == 2) ; Dinner
ElseIf (aiButton == 2) ; Dinner
aiButton = DinnerMESG.Show()
aiButton = DinnerMESG.Show()
If (aiButton == 0) ; Filet Mignon
If (aiButton == 0) ; Filet Mignon
ElseIf (aiButton == 1) ; Lobster
ElseIf (aiButton == 1) ; Pony Fajitas
ElseIf (aiButton == 2) ; Fried Chicken
ElseIf (aiButton == 2) ; Lobster
EndIf
EndIf
EndIf
EndIf
Line 80: Line 80:


EndFunction</source>
EndFunction</source>
*To make a multilevel, looping menu that will not close until a "Done" button is pressed, use the above method but with the Menu() function altered. Note that you can jump to a given message by specifying the aiMessage argument when calling the function. Sub-options as described in the previous example can be added to the below in the same manner. Theoretically, any number of options can be added with the below.
*To make a multilevel, looping menu with thirty buttons that will not close until a "Done" button is pressed using the above method but with an altered Menu() function. Note that you can jump to a given message by specifying the aiMessage argument when calling the function. Sub-options as described in the previous example can be added to the below in the same manner. Theoretically, any number of options can be added with the below structure.
<source lang="papyrus">
<source lang="papyrus">
Function Menu(Int aiMessage = 0, Int aiButton = 0, Bool abMenu = True)
Function Menu(Int aiMessage = 0, Int aiButton = 0, Bool abMenu = True)
Anonymous user

Navigation menu