MCM assistance please

Post » Tue Apr 09, 2013 9:52 pm

Greetings everyone. I didn't see where else to go with this so I'm posting it here. I'm leaving for vacation soon and wanted to get this out before then. This may be a simple coding oversight that I don't see so if anyone can help me with fresh eyes I would be most grateful.

I'm trying to create a simple toggle in the MCM to enable or disable my mod. All the elements needed are showing up correctly on the MCM and the toggle box works ok, but it is not turning my mod off. When the toggle box is checked (aVal/1/true/default) the mod is on. When the box is checked to disable it stays on though. The action that should be taken is a globalvariable value command 'ShelterSwitch.setvalue(1) [on] or (0) [off]'. I suspect I may not be using an If/Else statement correctly (within the ======= for reference). Here is the code if someone can take a quick look.

If someone can help me fix this I'll order an extra margarita for you :)

Scriptname RealShelterConfigScript extends SKI_ConfigBase  Globalvariable Property ShelterSwitch Autoint aOIDbool aVal = Truebool bVal = falseEvent OnPageReset(string page)  SetCursorFillMode(TOP_TO_BOTTOM)  AddHeaderOption("Toggle Real Shelter")  aOID = AddToggleOption("Enable", aVal)EndEvent;================================Event OnOptionSelect(int option)  If (option == aOID)    aVal = !aVal    SetToggleOptionValue(aOID, aVal)    ShelterSwitch.setvalue(1)  Else    bVal = !bVal    SetToggleOptionValue(aOID, bVal)    ShelterSwitch.setvalue(0)  EndIfEndEvent;================================Event OnOptionHighlight(int option)  If (option == aOID)    SetInfoText("Toggles Real Shelter on or off")  EndIfEndEventEvent OnOptionDefault(int option)  If (option == aOID)    aVal = true    SetToggleOptionValue(aOID, aVal)  EndIfEndEvent
User avatar
R.I.P
 
Posts: 3370
Joined: Sat Dec 01, 2007 8:11 pm

Post » Wed Apr 10, 2013 10:15 am

I'm at work so can't test, but something like this I believe...

Scriptname RealShelterConfigScript extends SKI_ConfigBase  Globalvariable Property ShelterSwitch Autoint aOIDbool aVal = TrueEvent OnPageReset(string page)  SetCursorFillMode(TOP_TO_BOTTOM)  AddHeaderOption("Toggle Real Shelter")  aOID = AddToggleOption("Enable", aVal)EndEventEvent OnOptionSelect(int option)  If (option == aOID)    aVal = !aVal    SetToggleOptionValue(aOID, aVal)    If aVal          ShelterSwitch.setvalue(1)    Else      ShelterSwitch.setvalue(0)    EndIf  EndIfEndEventEvent OnOptionHighlight(int option)  If (option == aOID)    SetInfoText("Toggles Real Shelter on or off")  EndIfEndEventEvent OnOptionDefault(int option)  If (option == aOID)    aVal = true    SetToggleOptionValue(aOID, aVal)    ShelterSwitch.setvalue(1)  EndIfEndEvent
User avatar
Nicola
 
Posts: 3365
Joined: Wed Jul 19, 2006 7:57 am


Return to V - Skyrim