Open main menu
Home
Random
Log in
Settings
About the CreationKit Wiki
Disclaimers
the CreationKit Wiki
Search
Editing
Options Menu
(section)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Multilevel, looping menu == To make a multilevel, looping menu with thirty buttons that will not close until a "Done" button is pressed, use 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. By making it conditional, we can check its property values with MessageBox buttons using [[GetVMScriptVariable]] and pointing to the placed instance of the item this script is attached to. To ensure the player gets said reference, make a property for the specific reference in another script, and add it to the player with [[AddItem]] by passing the reference as akItemToAdd. <syntaxhighlight lang="papyrus">ScriptName OptionsMenuScript Extends ObjectReference Conditional Actor Property PlayerREF Auto Armor Property MenuARMO Auto ; Playable apparel item Bool Property bFeatureEnabled Auto Conditional ; Toggling of this demonstrated below. GlobalVariable Property DragonsEnabled Auto ; Toggling of this demonstrated below. Message Property OptionsMenu00MESG Auto Message Property OptionsMenu01MESG Auto Message Property OptionsMenu02MESG Auto YourQuestScriptName Property QuestScript Auto ; Is Conditional with a Conditional bQuickening property Event OnEquipped(Actor akActor) If akActor == PlayerREF Game.DisablePlayerControls(False, False, False, False, False, True) ; Momentarily disable other menus PlayerREF.EquipItem(MenuARMO, True, True) ; Prevent unequip/reequip in favorites until the current menu is resolved Utility.Wait(0.01) ; This ensures equipping the token from the favorites menu works PlayerREF.UnequipItem(MenuARMO, False, True) ; Silently unequip item Game.EnablePlayerControls(False, False, False, False, False, True) ; Undo DisablePlayerControls Menu() EndIf EndEvent Function Menu(Int aiMessage = 0, Int aiButton = 0, Bool abMenu = True) While abMenu If aiButton == -1 ; As above, can prevent problems if recycling aiButton ElseIf aiMessage == 0 aiButton = OptionsMenu00MESG.Show() If aiButton < 2 ; Toggle script property. Buttons have opposite GetVMScriptVariable conditions so only the applicable option is given. bFeatureEnabled = !bFeatureEnabled ; Set boolean to whatever it is not If bFeatureEnabled ; == True Debug.Trace("Featured enabled. Set things up.") Else ; If bFeatureEnabled == False Debug.Trace("Featured disabled. Stop doing stuff and clean up.") EndIf ElseIf aiButton < 4 ; Toggle quest property. Buttons have opposite conditions checking the property value with GetVMQuestVariable. QuestScript.bQuickening = !QuestScript.bQuickening ; Set boolean to whatever it is not If QuestScript.bQuickening ; == True Debug.Trace("Start polling.") Else ; If QuestScript.bQuickening == False Debug.Trace("Stop polling.") EndIf ElseIf aiButton < 6 ; Toggle DragonsEnabled. Buttons have opposite conditions as above, but checking the global's value with GetGlobalValue. DragonsEnabled.SetValue((!DragonsEnabled.GetValue() As Bool) As Float) ; If 1, set to 0. If 0, set to 1 If DragonsEnabled.GetValue() ; != 0 Debug.Trace("Dragons enabled.") Else ; If DragonsEnabled.GetValue() == 0 Debug.Trace("Dragons disabled.") EndIf ElseIf aiButton == 6 ElseIf aiButton == 7 ElseIf aiButton == 8 ; More aiMessage = 1 ElseIf aiButton == 9 ; Done abMenu = False EndIf ElseIf aiMessage == 1 aiButton = OptionsMenu01MESG.Show() If aiButton == 0 ElseIf aiButton == 1 ElseIf aiButton == 2 ElseIf aiButton == 3 ElseIf aiButton == 4 ElseIf aiButton == 5 ElseIf aiButton == 6 ElseIf aiButton == 7 ; Back aiMessage = 0 ElseIf aiButton == 8 ; More aiMessage = 2 ElseIf aiButton == 9 ; Done abMenu = False EndIf ElseIf aiMessage == 2 aiButton = OptionsMenu02MESG.Show() If aiButton == 0 ElseIf aiButton == 1 ElseIf aiButton == 2 ElseIf aiButton == 3 ElseIf aiButton == 4 ElseIf aiButton == 5 ElseIf aiButton == 6 ElseIf aiButton == 7 ElseIf aiButton == 8 ; Back aiMessage = 1 ElseIf aiButton == 9 ; Done abMenu = False EndIf EndIf EndWhile EndFunction</syntaxhighlight> === Notes === *Given the buttons in Skyrim are listed from side to side, it is easy to spill over the edges of the user's monitor, particularly if it's a 4:3, in the event either the options are too verbose or there are too many options presented by a single message form. Currently, there's no way to list them from top to bottom as they were in previous Bethesda games. To mitigate this, keep the button text to a minimum and/or make sure to always set up conditions on mutually exclusive buttons to ensure only applicable options are presented. *To conditionalize buttons using variables declared in your script/quest, use [[GetVMScriptVariable]] and [[GetVMQuestVariable]]. *To hide buttons you wish to fill in later, add an impossible condition like 'IsXBox == -1'. *For debugging purposes, you could configure hidden menu buttons (in the Message forms) that only show when you set a GlobalVariable flag. For instance, create a GlobalVariable called "myDebugFlag" in the CK. Set a condition on one of your menu buttons to be "GetGlobalValue myDebugFlag == 1". In your script, have that button activate your debugging function. Now if you set myGlobalValue to 1 in the CK your button will appear in the menu. Before releasing the mod, remember to set myDebugFlag to 0 to keep the button hidden. *Conditionalizing MessageBox buttons will not change their indices such that, for instance, button 9 will still execute the "Done" code in the last example even if buttons 0-8 are hidden. *To learn how to assign user-created messageboxes as values to the message box Properties defined in the above scripts, see [[Bethesda_Tutorial_Papyrus_Introduction_to_Properties_and_Functions#Hooking_up_the_message_boxes_to_the_properties_in_the_script|the Papyrus tutorial's page on Properties and Functions]] *If the Message Property isn't filled in the CK the Show() will always return a 0, '''and the Message will not be shown'''. *If the Message is a Notification (without buttons) instead of a Message Box the Show() will return a -1, '''in which case you will never be presented with an options menu'''. === See Also === [[Show - Message]] [[Category:Scripting]] [[Category:Papyrus]] [[Category:Papyrus_Tutorials]] [[Category:Tutorials]]
Summary:
Please note that all contributions to the CreationKit Wiki are considered to be released under the Creative Commons Attribution-ShareAlike (see
CreationKit:Copyrights
for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource.
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)