slizer40000 Posted April 13, 2022 Posted April 13, 2022 I'm at my wit's end regarding scripting MCM for the attached script Live_Action_MCM.psc. I originally had a problem with a text option not doing anything when the onselectST event triggers, i.e. when I click the text in the MCM. The function worked before but at some stage (months ago, and no, I did not separately save a functional version) stopped working. The Onhighlighttext text also does not appear at all, which is concerning. The variables and properties are declared and tied to the relevant quest in the CK, so I suspect a fundamental mistake. I attempted to circumvent the issue by converting the entry to a menu option. The script compiled successfully again, yet the menu option is also not working properly. Symptoms: the menu entries are missing and the menu is instead populated by entries from other MCM menu windows after I have opened another. I'd appreciate any help in this matter. It's the last thing to solve before I can release the next version. The relevant code is in spoilers: Spoiler Actor Property LiveActPuppetActor Auto; PC or valid NPC selected with key under crosshair. Int Property LiveAct_Save_Act_Profile = 5 Auto Hidden String[] Property LiveAct_Save_Act_Profile_Str Auto Hidden Int Property LiveAct_Load_Act_Profile = 5 Auto Hidden String[] Property LiveAct_Load_Act_Profile_Str Auto Hidden Function InstallMCM() ... String ProfileActor = LiveActPuppetActor.GetLeveledActorBase().GetName() LiveAct_Save_Act_Profile_Str = New String[4] LiveAct_Save_Act_Profile_Str[0] = ProfileActor LiveAct_Save_Act_Profile_Str[1] = "Custom profile 1" LiveAct_Save_Act_Profile_Str[2] = "Custom profile 2" LiveAct_Save_Act_Profile_Str[3] = "Custom profile 3" LiveAct_Load_Act_Profile_Str = New String[4] LiveAct_Load_Act_Profile_Str[0] = ProfileActor LiveAct_Load_Act_Profile_Str[1] = "Custom profile 1" LiveAct_Load_Act_Profile_Str[2] = "Custom profile 2" LiveAct_Load_Act_Profile_Str[3] = "Custom profile 3" EndFunction Function DisplayActorSettings(Actor akRef) AddMenuOptionST("OID_LiveAct_Actor_Save_Profile", "$Live_Action_Actor_Save_Profile", LiveAct_Save_Act_Profile_Str[LiveAct_Save_Act_Profile]) AddMenuOptionST("OID_LiveAct_Actor_Load_Profile", "$Live_Action_Actor_Load_Profile", LiveAct_Load_Act_Profile_Str[LiveAct_Load_Act_Profile]) EndFunction State OID_LiveAct_Save_Act_Profile event OnHighlightST() SetInfoText("$Live_Action_Save_Act_Profile_Desc") EndEvent Event OnMenuOpenST() SetMenuDialogStartIndex(LiveAct_Save_Act_Profile) SetMenuDialogDefaultIndex(5) SetMenuDialogOptions(LiveAct_Save_Act_Profile_Str) EndEvent Event OnMenuAcceptST(int a_index) If ShowMessage("Save Profile?", true, "$Yes", "$No") SetOptionFlagsST(OPTION_FLAG_DISABLED) LiveAct_Save_Act_Profile = a_index SetMenuOptionValueST(LiveAct_Save_Act_Profile_Str[a_index]) SaveActorToJson(LiveAct_Save_Act_Profile_Str[a_index]) ShowMessage(LiveAct_Save_Act_Profile_Str[a_index] + " saved.") Log("Profile saved.") SetOptionFlagsST(OPTION_FLAG_NONE) EndIf EndEvent Event OnDefaultST() LiveAct_Save_Act_Profile = 5 SetMenuOptionValueST(LiveAct_Save_Act_Profile_Str[5]) EndEvent EndState State OID_LiveAct_Load_Act_Profile event OnHighlightST() SetInfoText("$Live_Action_Load_Act_Settings_Desc") EndEvent Event OnMenuOpenST() SetMenuDialogStartIndex(LiveAct_Load_Act_Profile) SetMenuDialogDefaultIndex(5) SetMenuDialogOptions(LiveAct_Load_Act_Profile_Str) EndEvent Event OnMenuAcceptST(int a_index) If ShowMessage("Load Profile?", true, "$Yes", "$No") SetOptionFlagsST(OPTION_FLAG_DISABLED) LiveAct_Load_Act_Profile = a_index SetMenuOptionValueST(LiveAct_Load_Act_Profile_Str[a_index]) LoadActorFromJson(LiveAct_Load_Act_Profile_Str[a_index]) ShowMessage(LiveAct_Load_Act_Profile_Str[a_index]+ " loaded.") Log(LiveAct_Load_Act_Profile_Str[a_index]+ " loaded.") SetOptionFlagsST(OPTION_FLAG_NONE) EndIf EndEvent Event OnDefaultST() LiveAct_Load_Act_Profile = 5 SetMenuOptionValueST(LiveAct_Load_Act_Profile_Str[5]) EndEvent EndState Edit: For whoever might encounter a similar issue, check that the OID of the states are spelled correctly and are an exact match. In addition, MCM menu lists cannot be populated as in my example. Text strings without variables work fine. Inserting variables causes the menu list to disappear. The answer might lie with where the instance where the variable is introduced or changed. Also, the text option state works fine for saving to JSON. MO2 simply decided to redirect the generated files to an existing mod folder.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.