IsharaMeradin Posted March 17, 2014 Share Posted March 17, 2014 I'm trying to set up an MCM menu option. It is my first one (not MCM but the menu option). I'm having a little trouble figuring out what to do. I've pretty much mimic'd the example and now I'm stuck with the OnOptionMenuAccept event.The quickstart example follows: event OnOptionMenuAccept(int option, int index) if (option == difficultyOID_M) difficultyIndex = index SetMenuOptionValue(difficultyOID_M, difficultyList[difficultyIndex]) endIf endEvent Using that as a guide, how do I determine which option the user selected so that I can have something done? I'm allowing the user to select which body slot they would like a particular accessory to use (so they can configure around their existing gear). My gut tells me it is the index value and that I would want to add inside the OID if statement If index == 0;do stuffElseIf index == 1;do stuffEndIf What is confusing me further is the example sets the "difficultyIndex" to 1, but arrays by default start at 0. Does the example set it to 1 for default purposes or does the "behind the scenes stuff" shift the index to start with 1 instead of 0? Any information that can help shed light on this would be greatly appreciated. Thank you. Link to comment Share on other sites More sharing options...
schlangster Posted March 17, 2014 Share Posted March 17, 2014 (edited) "Using that as a guide, how do I determine which option the user selected so that I can have something done?" As you suspected, it's indicated by the index. The default index in the example is set to 1 because it defaults to "Normal", which is at index 1 of difficultyList. Edited March 17, 2014 by schlangster Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 17, 2014 Author Share Posted March 17, 2014 Alright. Thank you. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 18, 2014 Author Share Posted March 18, 2014 Another issue. Cannot get the menu entries to actually show up. The menu box opens but is completely blank. The entire script is below. It compiles, just does not show any options inside the menu option box. Any help getting this figured out would be appreciated. Scriptname abimIMSMCMQuestScript extends SKI_ConfigBase ; SCRIPT VERSION ---------------------------------------------------------------------------------- int function GetVersion() return 1 ; Default version endFunction ; PRIVATE VARIABLES ------------------------------------------------------------------------------- String[] MeshOptions ; OIDs (T:Text B:Toggle S:Slider M:Menu, C:Color, K:Key) int _myTextOID_T int _myToggle_OID_B int _mySliderOID_S int _myMenuOID_M int _myColorOID_C int _myKeyOID_K int OIDAlchemy int OIDCooking int OIDEnchanting int OIDForge int OIDSkyForge int OIDSmelter int OIDTanning int OIDTemper int OIDBOH int OIDBOHMesh int OIDAutoStore bool UseAlchemy = false bool UseCooking = false bool UseEnchanting = false bool UseForge = false bool UseSkyForge = false bool UseSmelter = false bool UseTanning = false bool UseTemper = false bool UseBOH = false bool UseAutoStore = false Armor Property IPAlchemy Auto Armor Property IPCooking Auto Armor Property IPEnchanting Auto Armor Property IPForge Auto Armor Property IPSkyForge Auto Armor Property IPSmelter Auto Armor Property IPTanning Auto Armor Property IPTemper Auto Armor Property IPBOHm1 Auto {Invisible interactive piece} Armor Property IPBOHm2 Auto {Slot 58 piece} GlobalVariable Property UseBOHToggle Auto {GV that toggles the use of the bag of holding} GlobalVariable Property UseAutoStoreToggle Auto {GV that toggles auto store on/off} Actor Property PlayerRef Auto {Reference to player -- auto-fills} ; State int BOHMeshIndex = 0 ; ... ; Internal ; ... ; INITIALIZATION ---------------------------------------------------------------------------------- ; @implements SKI_ConfigBase event OnConfigInit() {Called when this config menu is initialized} ; ... endEvent ; @implements SKI_QuestBase event OnVersionUpdate(int a_version) {Called when a version update of this script has been detected} ; ... endEvent event OnInit() parent.OnInit() MeshOptions = new string[3] MeshOptions[0] = "NONE" MeshOptions[1] = "Invisible: no slot" MeshOptions[2] = "Visible: Slot 58" endEvent ; EVENTS ------------------------------------------------------------------------------------------ Event OnConfigClose() EndEvent ; @implements SKI_ConfigBase event OnPageReset(string a_page) {Called when a new page is selected, including the initial empty page} SetCursorFillMode(TOP_TO_BOTTOM) SetCursorPosition(0) AddHeaderOption("Category Containers") OIDAlchemy = AddToggleOption("IMS: Alchemy Materials", UseAlchemy) OIDCooking = AddToggleOption("IMS: Cooking Materials", UseCooking) OIDEnchanting = AddToggleOption("IMS: Enchanting Materials", UseEnchanting) OIDForge = AddToggleOption("IMS: Forge Materials", UseForge) OIDSkyForge = AddToggleOption("IMS: Sky Forge Materials", UseSkyForge) OIDSmelter = AddToggleOption("IMS: Smelter Materials", UseSmelter) OIDTanning = AddToggleOption("IMS: Tanning Materials", UseTanning) OIDTemper = AddToggleOption("IMS: Tempering Materials", UseTemper) SetCursorPosition(1) AddHeaderOption("System wide Settings") OIDAutoStore = AddToggleOption("Auto Store Items",UseAutoStore) AddHeaderOption("Convenience Containers") OIDBOH = AddToggleOption("IMS: Bag of Holding", UseBOH) If UseBOH == false OIDBOHMesh = AddMenuOption("Bag of Holding Mesh Options", MeshOptions[BOHMeshIndex],OPTION_FLAG_DISABLED) Else OIDBOHMesh = AddMenuOption("Bag of Holding Mesh Options", MeshOptions[BOHMeshIndex],OPTION_FLAG_NONE) EndIf ; ... endEvent ; @implements SKI_ConfigBase event OnOptionHighlight(int a_option) {Called when highlighting an option} if a_option == OIDAlchemy SetInfoText("Allows use of the Alchemy Materials category container") Elseif a_option == OIDCooking SetInfoText("Allows use of the Cooking Materials category container") Elseif a_option == OIDEnchanting SetInfoText("Allows use of the Enchanting Materials category container") Elseif a_option == OIDForge SetInfoText("Allows use of the Forge Materials category container") Elseif a_option == OIDSkyForge SetInfoText("Allows use of the Sky Forge Materials category container") Elseif a_option == OIDSmelter SetInfoText("Allows use of the Smelter Materials category container") Elseif a_option == OIDTanning SetInfoText("Allows use of the Tanning Materials category container") Elseif a_option == OIDTemper SetInfoText("Allows use of the Temper Materials category container") Elseif a_option == OIDBOH SetInfoText("Allows use of the Bag of Holding. Also causes category containers to be weightless.") Elseif a_option == OIDBOHMesh SetInfoText("Choice of body slot for Bag of Holding. The NONE selection provides weightless category containers only.") Elseif a_option == OIDAutoStore SetInfoText("ON/OFF toggle for automatic transfer of previously sorted items") EndIf ; ... endEvent ; @implements SKI_ConfigBase event OnOptionSelect(int a_option) {Called when a non-interactive option has been selected} if a_option == OIDAlchemy UseAlchemy = !UseAlchemy SetToggleOptionValue(OIDAlchemy, UseAlchemy) PlayerRef.AddItem(IPAlchemy,1,true) Elseif a_option == OIDCooking UseCooking = !UseCooking SetToggleOptionValue(OIDCooking, UseCooking) PlayerRef.AddItem(IPCooking,1,true) Elseif a_option == OIDEnchanting UseEnchanting = !UseEnchanting SetToggleOptionValue(OIDEnchanting, UseEnchanting) PlayerRef.AddItem(IPEnchanting,1,true) Elseif a_option == OIDForge UseForge = !UseForge SetToggleOptionValue(OIDForge, UseForge) PlayerRef.AddItem(IPForge,1,true) Elseif a_option == OIDSkyForge UseSkyForge = !UseSkyForge SetToggleOptionValue(OIDSkyForge, UseSkyForge) PlayerRef.AddItem(IPSkyForge,1,true) Elseif a_option == OIDSmelter UseSmelter = !UseSmelter SetToggleOptionValue(OIDSmelter, UseSmelter) PlayerRef.AddItem(IPSmelter,1,true) Elseif a_option == OIDTanning UseTanning = !UseTanning SetToggleOptionValue(OIDTanning, UseTanning) PlayerRef.AddItem(IPTanning,1,true) Elseif a_option == OIDTemper UseTemper = !UseTemper SetToggleOptionValue(OIDTemper, UseTemper) PlayerRef.AddItem(IPTemper,1,true) Elseif a_option == OIDBOH UseBOH = !UseBOH SetToggleOptionValue(OIDBOH, UseBOH) If UseBOH == true UseBOHToggle.SetValueInt(1) SetOptionFlags(OIDBOHMesh,OPTION_FLAG_NONE) Else UseBOHToggle.SetValueInt(0) SetOptionFlags(OIDBOHMesh,OPTION_FLAG_DISABLED) EndIf Elseif a_option == OIDAutoStore UseAutoStore = !UseAutoStore SetToggleOptionValue(OIDAutoStore, UseAutoStore) If UseAutoStore == true UseAutoStoreToggle.SetValueInt(1) Else UseAutoStoreToggle.SetValueInt(0) EndIf EndIf ; ... endEvent ; @implements SKI_ConfigBase event OnOptionDefault(int a_option) {Called when resetting an option to its default value} ; ... endEvent ; @implements SKI_ConfigBase event OnOptionSliderOpen(int a_option) {Called when a slider option has been selected} ; ... endEvent ; @implements SKI_ConfigBase event OnOptionSliderAccept(int a_option, float a_value) {Called when a new slider value has been accepted} ; ... endEvent ; @implements SKI_ConfigBase event OnOptionMenuOpen(int a_option) {Called when a menu option has been selected} if (a_option == OIDBOHMesh) SetMenuDialogOptions(MeshOptions) SetMenuDialogStartIndex(BOHMeshIndex) SetMenuDialogDefaultIndex(0) endIf ; ... endEvent ; @implements SKI_ConfigBase event OnOptionMenuAccept(int a_option, int a_index) {Called when a menu entry has been accepted} if (a_option == OIDBOHMesh) BOHMeshIndex = a_index SetMenuOptionValue(OIDBOHMesh, MeshOptions[BOHMeshIndex]) If a_index == 0 ElseIf a_index == 1 PlayerRef.AddItem(IPBOHm1,1,true) ElseIf a_index == 2 PlayerRef.AddItem(IPBOHm2,1,true) EndIf endIf ; ... endEvent ; @implements SKI_ConfigBase event OnOptionColorOpen(int a_option) {Called when a color option has been selected} ; ... endEvent ; @implements SKI_ConfigBase event OnOptionColorAccept(int a_option, int a_color) {Called when a new color has been accepted} ; ... endEvent ; @implements SKI_ConfigBase event OnOptionKeyMapChange(int a_option, int a_keyCode, string a_conflictControl, string a_conflictName) {Called when a key has been remapped} ; ... endEvent Papyrus log output when I access the menu [03/18/2014 - 05:54:23PM] Error: Array index -1 is out of range (0-2) stack: [abimIMSMCMQuest (090048E2)].abimIMSMCMQuestScript.OnOptionMenuAccept() - "abimIMSMCMQuestScript.psc" Line 256 [abimIMSMCMQuest (090048E2)].abimIMSMCMQuestScript.SetMenuIndex() - "SKI_ConfigBase.psc" Line 1042 [SKI_ConfigManagerInstance (0A000802)].SKI_ConfigManager.OnMenuAccept() - "SKI_ConfigManager.psc" Line 210 I've never created arrays in a script before. Any array I've used was property filled, I suppose I could be doing something wrong in that regard. I have tried putting the array creation inside the OnConfigInit() as well as in the OnInit() event shown above. Both got the same results. I even removed the SDK prior to testing and got the same. I should note that I'm testing by doing coc qasmoke from the main menu. So it should all be fresh and not have any prior remnants behind. FYI - I know that I need to specify a specific page for the various options as well as default settings where possible and I will get to it. First, however, I need to get this menu working. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 18, 2014 Author Share Posted March 18, 2014 I modified the OnInit() event as shown above to the following event OnInit() parent.OnInit() MeshOptions = new string[3] MeshOptions[0] = "NONE" MeshOptions[1] = "Invisible: no slot" MeshOptions[2] = "Visible: Slot 58" Int x = 0 Int y = MeshOptions.Length While x < y Debug.Trace("MeshOptions["+x+"] : "+MeshOptions[x]) x += 1 EndWhile endEvent Result: [03/18/2014 - 07:12:59PM] [abimIMSMCMQuestScript <abimIMSMCMQuest (090048E2)>] INITIALIZED [03/18/2014 - 07:12:59PM] MeshOptions[0] : None [03/18/2014 - 07:12:59PM] MeshOptions[1] : Invisible: no slot [03/18/2014 - 07:12:59PM] MeshOptions[2] : Visible: Slot 58 According to that the data is there. So I guess I've done something wrong with the MCM structure. But what, no idea... Link to comment Share on other sites More sharing options...
Xander9009 Posted March 19, 2014 Share Posted March 19, 2014 (edited) My best guess would be to see if you have a page in the Pages array. There are appearing no matter the page, so you might have left the array empty for testing, but that empty array might be causing an issue. I don't see anything wrong with it at first glance. If that doesn't help, I'll try debugging it and see if I can come up with anything. Yeah, the arrays are set up right. And I think the OnConfigInit is run when SkyUI registers it while OnInit is run at game startup and when the quest starts (so, twice when the game starts for game start enabled quests). Edited March 19, 2014 by Xander9009 Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 19, 2014 Author Share Posted March 19, 2014 It was a nice thought but despite setting it up to show on only one page the menu still was empty. I even went and set the array up as a property and filled it within the CK. No dice. There has to be something I'm missing with the MCM stuff for it. What that might be, I've no idea. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 19, 2014 Author Share Posted March 19, 2014 You know after a bunch of trial and error I finally found the problem. You cannot assign NONE as one of the menu options in the array. Link to comment Share on other sites More sharing options...
Xander9009 Posted March 19, 2014 Share Posted March 19, 2014 That seems odd. At least you found it, though. I was going to start messing with it soon (I just woke up), but I'm not sure I would have noticed it. Link to comment Share on other sites More sharing options...
IsharaMeradin Posted March 19, 2014 Author Share Posted March 19, 2014 I know. It took taking the example on the quickstart pages and doing a test mod with it. When that worked, I grafted it into my mod. When that worked, I commented out my menu option stuff and changed first the variable names to match my structure. When that worked, I added the enable/disable based on the one toggle. Finally when that worked, I changed the string values. Once I put NONE in, that was when it stopped working. I would have never thought of that if I hadn't replaced everything one piece at a time. Link to comment Share on other sites More sharing options...
Recommended Posts