dizietemblesssma Posted October 2, 2023 Share Posted October 2, 2023 I'm not completely sure how to interpret the following errors:1. Option type mismatch. Expected text option, page "", index 2it seems that I'm being told that a text option was expected, but what is page "" referring to? If it means the MCM page "" in my script then that doesn't make sense If page == "" ;is this the top page LoadCustomContent("diziet/bath_undressing.dds") ;show image return else UnloadCustomContent() EndIfis the "index 2" referring to a parameter of said text option? With no line numbers in the papyrus.0.log for these errors I'm not sure how to move on. 2. ERROR: Cannot use SetTextOptionValueST outside a valid option statenot sure what "valid option state" means, is an "option state" the same as a state in the MCM script? Again no line numbers in the log. diziet Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 2, 2023 Share Posted October 2, 2023 #1Make sure that the variable 'page' that you are using is the correct parameter variable as found in the OnPageReset event line. See example: Event OnPageReset(string page) If page == "" LoadCustomContent("abim/IMS_Title.dds") Else UnLoadCustomContent() EndIf If you are cobbling code from examples it is possible that you've gotten a mix-up. This is especially true since the SkyUI SDK provides an SKI_ConfigBase script along with several working examples that use: event OnPageReset(string a_page) While it also shows in the API itself: Event OnPageReset(string page) Just remember that parameters in a function or event are just variable names used for those passed in object types within the event or function. As long as you are consistent within the function or event, you could use anything you want. #2All the ST set options need to be handled inside their associated ST events while inside a state. Here is a small working example: ;================================ ;==== KeyMap_One State ==== ;================================ GlobalVariable Property abim_IMS_ModActKeyGV Auto State KeyMap_One Event OnKeyMapChangeST(int newKeyCode, string conflictControl, string conflictName) KeyCodeOne = newKeyCode abim_IMS_ModActKeyGV.SetValue(KeyCodeOne as float) SetKeyMapOptionValueST(KeyCodeOne) EndEvent Event OnDefaultST() KeyCodeOne = -1 abim_IMS_ModActKeyGV.SetValue(KeyCodeOne as float) SetKeyMapOptionValueST(KeyCodeOne) EndEvent Event OnHighlightST() SetInfoText("$MAKInfo") EndEvent EndState Should that information not help you find and rectify the issue. Feel free to post the compiler error that you are getting along with the script code causing the error. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 2, 2023 Author Share Posted October 2, 2023 My dds image displays fine:)The error message is from a user and I'm trying to help but can't work out what the error is referring to when it says ' page"" ', since I don't get that error:) So this function: Function dz_fill_npc_slots_used()DEBUG_TRACE(NONE,"function dz_fill_npc_slots_used - teammate is "+teammate)If teammate teammate_name = teammate.GetBaseObject().GetName() ShowMessage("$npc_slots_message_text",False) Int i i = 30 While i < 62 Int j = i - 30 ;for the following debug messages If teammate.GetEquippedArmorInSlot(i).GetName() _npc_text_slots[i - 30] = teammate.GetEquippedArmorInSlot(i).GetName() DEBUG_TRACE(NONE,"function dz_fill_npc_slots_used - settextoptionvaluest - _npc_text_slots["+ j +"]") SetTextOptionValueST(_npc_text_slots[i - 30]) Else _npc_text_slots[i - 30] = "$Empty" DEBUG_TRACE(NONE,"function dz_fill_npc_slots_used - settextoptionvaluest - _npc_text_slots["+ j +"]") SetTextOptionValueST(_npc_text_slots[i - 30]) EndIf i = i +1 EndWhileElse ShowMessage("$npc_slots_message_text2",False)EndIfForcePageReset()EndFunction which has SetTextValueOptionST in it would it work if called from a state definition so: State state_get_npc_slotsEvent OnSelectST() _toggle_get_npc_slots = !_toggle_get_npc_slots SetToggleOptionValueST(_toggle_get_npc_slots) If _toggle_get_npc_slots == True dz_fill_npc_slots_used() ElseIf _toggle_get_npc_slots == False dz_empty_npc_slots_used() EndIfEndEventEndState whereas this is wrong?: If page == "$npc_slots_used" SetTitletext("$npc_slots_used") SetCursorFillMode(TOP_TO_BOTTOM) AddHeaderOption("$Examine_an_NPC's_slots") AddToggleOptionST("state_get_npc_slots","$get_npc_slots_text",_toggle_get_npc_slots) AddTextOptionST("state_text_get_npc_slots","$npc_name",teammate_name) Int i i = 30 While i < 46 AddHeaderOption("$Slot_"+i) AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) SetTextOptionValueST(_npc_text_slots[i - 30]) i = i + 1 EndWhile SetCursorPosition(7) SetCursorFillMode(TOP_TO_BOTTOM) i = 46 While i < 62 AddHeaderOption("$Slot_"+i) AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) SetTextOptionValueST(_npc_text_slots[i - 30]) i = i + 1 EndWhileEndIf Since th SetTextOptionValueST is in the page defintion part? The full MCM script is here but it is thousands of lines:https://pastebin.com/6mB52GWu the user's error messages I am trying to decipher are here:https://pastebin.com/qLfvdVzN diziet Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 3, 2023 Share Posted October 3, 2023 It should work from within a state definition, yes. In fact, there error log states as much [09/27/2023 - 01:30:15PM] [dz_undress_mcm_menu_script <dz_undress_MCM_menu (FE0BED63)>] ERROR: Cannot use SetTextOptionValueST outside a valid option state I think if you fix the issue with the SetTextOptionValueST, the other issue will correct itself. I could be wrong, but start with fixing the one and then seeing what happens. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 3, 2023 Author Share Posted October 3, 2023 That seems likely, leading me to wonder, in this: SetCursorPosition(7) SetCursorFillMode(TOP_TO_BOTTOM) i = 46 While i < 62 AddHeaderOption("$Slot_"+i) AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) SetTextOptionValueST(_npc_text_slots[i - 30]) i = i + 1 EndWhile the filling of the right of the page with text option states works fine, if the SetTextOptionValueST cannot be called here then would it suffice to use another function to fill the values of _npc_text_slots[] _before_ the AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) line? diziet Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 4, 2023 Share Posted October 4, 2023 If you need to pre-populate the data in order to display it on the options page, consider calling a custom function that fills the appropriate array from within the OnConfigOpen event. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 4, 2023 Author Share Posted October 4, 2023 If you need to pre-populate the data in order to display it on the options page, consider calling a custom function that fills the appropriate array from within the OnConfigOpen event. That sounds good, for anyone googling this, I have found that the SetTextOptionValueST function that is in this function: Function dz_fill_npc_slots_used() DEBUG_TRACE(NONE,"function dz_fill_npc_slots_used - teammate is "+teammate) If teammate teammate_name = teammate.GetBaseObject().GetName() ShowMessage("$npc_slots_message_text",False) Int i i = 30 While i < 62 Int j = i - 30 ;for the following debug messages If teammate.GetEquippedArmorInSlot(i).GetName() _npc_text_slots[i - 30] = teammate.GetEquippedArmorInSlot(i).GetName() DEBUG_TRACE(NONE,"function dz_fill_npc_slots_used - settextoptionvaluest - _npc_text_slots["+ j +"]") SetTextOptionValueST(_npc_text_slots[i - 30]) Else _npc_text_slots[i - 30] = "$Empty" DEBUG_TRACE(NONE,"function dz_fill_npc_slots_used - settextoptionvaluest - _npc_text_slots["+ j +"]") SetTextOptionValueST(_npc_text_slots[i - 30]) EndIf i = i +1 EndWhile Else ShowMessage("$npc_slots_message_text2",False) EndIf ForcePageReset() EndFunction is not actually ok even though the function is called from within a state. The reason it appears to work is the ForcePageReset() at the end! :smile: I feel a bit silly because I should have tested that earlier, in fact if insert the function code into the OnSelectST event code it still doesn't work. neither does this: State state_get_npc_slots Event OnSelectST() _toggle_get_npc_slots = !_toggle_get_npc_slots SetToggleOptionValueST(_toggle_get_npc_slots) If _toggle_get_npc_slots == True ;dz_fill_npc_slots_used() DEBUG_TRACE(NONE,"function dz_fill_npc_slots_used - teammate is "+teammate) If teammate teammate_name = teammate.GetBaseObject().GetName() ShowMessage("$npc_slots_message_text",False) Int i i = 30 While i < 62 Int j = i - 30 ;for the following debug messages SetTextOptionValueST("test",False,"state_get_npc_slots") i = i +1 EndWhile Else ShowMessage("$npc_slots_message_text2",False) EndIf ;ForcePageReset() ElseIf _toggle_get_npc_slots == False dz_empty_npc_slots_used() EndIf EndEvent EndState I believe I understand the flaw in my thinking, in this code: If page == "$npc_slots_used" SetTitletext("$npc_slots_used") SetCursorFillMode(TOP_TO_BOTTOM) AddHeaderOption("$Examine_an_NPC's_slots") AddToggleOptionST("state_get_npc_slots","$get_npc_slots_text",_toggle_get_npc_slots) AddTextOptionST("state_text_get_npc_slots","$npc_name",teammate_name) Int i i = 30 While i < 46 AddHeaderOption("$Slot_"+i) AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) ;SetTextOptionValueST(_npc_text_slots[i - 30]) i = i + 1 EndWhile SetCursorPosition(7) SetCursorFillMode(TOP_TO_BOTTOM) i = 46 While i < 62 AddHeaderOption("$Slot_"+i) AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) ;SetTextOptionValueST(_npc_text_slots[i - 30]) i = i + 1 EndWhile EndIf which works, I create 32 textoptions, I think that each of these is actually a state even though I do not have a state section in my code for any of them. The page shows the text options, and when i fill the _npc_text_slots[] array and forcepagereset or go to another page and back the testoption states have updated. This was always trying to use the SetTextOptionValueST() where it couldn't possibly work since it was attempting to update a textoption outside of its state OnSelectST() event when there was no OnSelectST() event for that state! diziet Link to comment Share on other sites More sharing options...
IsharaMeradin Posted October 4, 2023 Share Posted October 4, 2023 If you have 32 text options and you want to use the state route, you'll need 32 states each with their own set of events and code to go within. If they are similar, you can do copy paste and modify accordingly. Link to comment Share on other sites More sharing options...
dizietemblesssma Posted October 5, 2023 Author Share Posted October 5, 2023 Actuallly I've had this MCM menu working for a few years now, with the code: If page == "$npc_slots_used" SetTitletext("$npc_slots_used") SetCursorFillMode(TOP_TO_BOTTOM) AddHeaderOption("$Examine_an_NPC's_slots") AddToggleOptionST("state_get_npc_slots","$get_npc_slots_text",_toggle_get_npc_slots) AddTextOptionST("state_text_get_npc_slots","$npc_name",teammate_name) Int i i = 30 While i < 46 AddHeaderOption("$Slot_"+i) AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) ;SetTextOptionValueST(_npc_text_slots[i - 30]) i = i + 1 EndWhile SetCursorPosition(7) SetCursorFillMode(TOP_TO_BOTTOM) i = 46 While i < 62 AddHeaderOption("$Slot_"+i) AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) ;SetTextOptionValueST(_npc_text_slots[i - 30]) i = i + 1 EndWhileEndIf sucessfully creating the menu options.I was pointing out that because I don't have/need a written section for each text option state, I then fell into the trap of not noticing that when I called the SetTextOptionValueSt() function it was not in a written state for that option.Turns out that for the past few years my code also set the parameter set in the AddTextOptionST("$slot"+i,"",_npc_text_slots[i - 30]) elsewhere and the later ForcepageReset() did the job! [:)]I never actually needed the SetTextOptionValueST(), all it did was give me errors, now that's embarrassing:) diziet Link to comment Share on other sites More sharing options...
PeterMartyr Posted October 5, 2023 Share Posted October 5, 2023 LOL I quickly worked out your using Runtime States, cos the armor can OFC vary ... OGM if I had to explain to you how use automatically generated states at runtime, I would rather kill myself. I am sure creating a various "proper states" that handle the potential variations, will work, BUT THAT NOT WAY YOU DO IT... heheheheehe you need to handle states generated at runtime in an open state, just saying It needs to be 100% dynamic OK? hardcoding some states like I said will work, but creating 30 hardcoded states is a lot work for no gain, where all potential 30 could be handled by just one. Put this way the code should scale OK, should slots increase to 100, hypothetically, it should just adapt with no changes required out of the box. Has well as also scaling down for example you are naked. BTW the papyrus log "ERRORS" are actually the game engine handing code that was not correctly validated before running.. so lift your game mate, a good example of a user who helps in these forums, while alway validating his code before running is redragon... if anyone uses his code correctly you never get a papyrus log error. Basicly a Papyrus Log Error is the game engine catching an exception in the code that should have, would have caused a "maybe" CTD. Depending on the severity ¯\_(ツ)_/¯ BIG EDIT I had a tiny thought, your just trying to display the armor slots while not manipulating it, why are you even using states? OVER KILL anyone? Just use a plain text options Form[] akItems = PlayerRef.GetContainerForms() Int nIndex = akItems.Length While nIndex nIndex -= 1 Armor akArmor = akItems[nIndex] As Armor If akArmor != None && akArmor.IsPlayable() == True If PlayerRef.IsEquipped(akArmor) self.AddTextOption(akArmor.GetName(), GetbodySlot(akArmor.GetSlotMask())) EndIf EndIf EndWhile If you want to say click on it and get the armor rating yeah you need states, just to display it, no, btw I kept it simple, I could listed the the armor in inventory he was not wearing Link to comment Share on other sites More sharing options...
Recommended Posts