I've been struggling with detecting when MenuMode becomes active.
This method is the closest that I can get to an OnMenuMode () Event.
Has anyone found a better way?
The set-up:
1. Quest with this Script.
The function is written so that it looks like and is used like an Event.
Spoiler
Scriptname kuDetectMenuModeQS extends QuestBool wasInMenuModeFunction OnMenuMode () ;menuMode triggered wasInMenuMode = TrueEndFunctionEvent OnUpdate () If wasInMenuMode ;coming back from MenuMode wasInMenuMode = False EndIfEndEvent
2. Player Alias with this Script.
It is Unfortunate that this Script will trigger OnMenuMode () only if something changes on the player - not exactly when they enter MenuMode.
But I think it's a good enough approximation - especially if your OnUpdate () needs to know if the player has returned from MenuMode.
Are there any other events we can attach to the Player where we can call IsInMenuMode ()?
Spoiler
Scriptname kuAFTPVPlayerS extends ReferenceAlias Event OnItemAdded(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akSourceContainer) kuAFTPVQS mainQuest = GetOwningQuest () as kuDetectMenuModeQS If Utility.IsInMenuMode () mainQuest.OnMenuMode () EndIfEndEventEvent OnItemRemoved(Form akBaseItem, int aiItemCount, ObjectReference akItemReference, ObjectReference akDestContainer) kuDetectMenuModeQS mainQuest = GetOwningQuest () as kuDetectMenuModeQS If Utility.IsInMenuMode () mainQuest.OnMenuMode () EndIfEndEventEvent OnMagicEffectApply(ObjectReference akCaster, MagicEffect akEffect) kuDetectMenuModeQS mainQuest = GetOwningQuest () as kuDetectMenuModeQS If Utility.IsInMenuMode () mainQuest.OnMenuMode () EndIfEndEventEvent OnObjectEquipped(Form akBaseObject, ObjectReference akReference) kuDetectMenuModeQS mainQuest = GetOwningQuest () as kuDetectMenuModeQS If Utility.IsInMenuMode () mainQuest.OnMenuMode () EndIfEndEventEvent OnObjectUnequipped(Form akBaseObject, ObjectReference akReference) kuDetectMenuModeQS mainQuest = GetOwningQuest () as kuDetectMenuModeQS If Utility.IsInMenuMode () mainQuest.OnMenuMode () EndIfEndEvent
Of course with better checking in the Player Alias Script, we can determine which Menu is active.
E.g. using the container parameter of OnAddItem () and OnRemovedItem () will tell us if the Player is with a merchant or looting a container.


I just wanted to avoid any possible confusion from my suggested code.