Difference between revisions of "Options Menu"
Jump to navigation
Jump to search
m
Changed second example to use a book
imported>JustinOther m (GetBaseObject() replaced with MenuARMO) |
imported>JustinOther m (Changed second example to use a book) |
||
Line 28: | Line 28: | ||
EndEvent</source> | EndEvent</source> | ||
*For the next example, we'll offer sub-options for each main selection. For a multilevel menu, a function works well. Keep in mind each button can have conditions, so you could hide "Lunch" and "Dinner" if it's time for breakfast or hide "Lobster" if it's not currently available. In this case, to make it repeatable, we'll use a | *For the next example, we'll offer sub-options for each main selection. For a multilevel menu, a function works well. Keep in mind each button can have conditions, so you could hide "Lunch" and "Dinner" if it's time for breakfast or hide "Lobster" if it's not currently available. In this case, to make it repeatable, we'll use a book so the menu will show each time it read. A book cannot be favorited or hotkeyed. | ||
<source lang="papyrus">ScriptName OptionsMenuScript extends ObjectReference | <source lang="papyrus">ScriptName OptionsMenuScript extends ObjectReference | ||
Armor Property | Armor Property MenuBook Auto | ||
Message Property MainMenuMESG Auto | Message Property MainMenuMESG Auto | ||
Message Property BreakfastMESG Auto | Message Property BreakfastMESG Auto | ||
Line 38: | Line 38: | ||
Message Property DinnerMESG Auto | Message Property DinnerMESG Auto | ||
Event | Event OnRead() | ||
Game.DisablePlayerControls(False, False, False, False, False, True) ; Momentarily disable other menus | |||
Game.EnablePlayerControls(False, False, False, False, False, True) ; Undo DisablePlayerControls | |||
Menu() | |||
EndEvent | EndEvent | ||
Line 81: | Line 76: | ||
EndFunction</source> | EndFunction</source> | ||
*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. | *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. | ||
<source lang="papyrus"> | <source lang="papyrus">ScriptName OptionsMenuScript extends ObjectReference | ||
Armor Property MenuARMO Auto ; Playable apparel item | |||
Message Property OptionsMenu00MESG Auto | |||
Message Property OptionsMenu01MESG Auto | |||
Message Property OptionsMenu02MESG Auto | |||
Event OnEquipped(Actor akActor) | |||
If akActor == Game.GetPlayer() | |||
Game.DisablePlayerControls(False, False, False, False, False, True) ; Momentarily disable other menus | |||
Game.GetPlayer().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 | |||
Game.GetPlayer().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) | Function Menu(Int aiMessage = 0, Int aiButton = 0, Bool abMenu = True) | ||