Jump to content

Need some help with MCM script & menu option


kryptopyr

Recommended Posts

I'm having trouble getting a menu option to work correctly in MCM. The menu option shows up on the screen (and disables/enables as it should based on a toggle option). But the text for the menu doesn't appear.

 

Currently, "EASY" shows up next to the menu option when the page is first loaded. However, when you select the menu, and the selection box pops up, there are no options to choose from (just a blank box). Also, when you tab out of the menu box, the "EASY" text disappears and there is no longer any text at all next to the option.

 

I've tried configuring the script in several different ways, putting the PresetList string in the OnConfigInIt, in an OnInIt event, etc. Nothing seems to make the text appear in the menu. I've compared the script to several other MCM config scripts from other mods, and as far as I can tell, it's set up the same way the others are.

 

Here is the script. The script compiles fine with no errors. I've edited out what I consider to be irrelevant parts, but I'll attach the full script to the post in case I'm wrong about what's relevant to the problem. If anyone has any suggestions, please let me know.

Scriptname TV_MCMScript extends SKI_ConfigBase

int OIDPresetRates
int OIDBarterMin
int OIDBarterMax
int OIDBuyBuff
int OIDSellBuff

int OIDUseBarterRates = 0
int OIDModStatus = 0
GlobalVariable property TV_State auto

float BarterMinVal = 2.0
float BarterMaxVal = 3.3
float BuyBuffVal = 0.0
float SellBuffVal = 0.0

GlobalVariable property TVModStatus auto
GlobalVariable property UseBarterSettings auto
GlobalVariable property BarterMinGlobal auto
GlobalVariable property BarterMaxGlobal auto
GlobalVariable property BuyBuffGlobal auto
GlobalVariable property SellBuffGlobal auto

string[] PresetList
int PresetChoice = 1

event OnConfigInit()
   Pages = new string[2]
   Pages[0] = "Price Variables"
   Pages[1] = "Merchants"
endEvent


function SetPresets()
   PresetList = new string[5]
   PresetList[0] = "None"
   PresetList[1] = "Easy"
   PresetList[2] = "Medium"
   PresetList[3] = "Difficult"
   PresetList[4] = "Hardcore"
endfunction

event OnPageReset(string page)
   if (page == "")
      SetPresets()
      SetCursorFillMode(TOP_TO_BOTTOM)
      if TVModStatus.getValue() == 1
         AddHeaderOption("Barter Rates")
         if UseBarterSettings.GetValueInt() == 0
            OIDPresetRates = AddMenuOption("Barter Presets", PresetList[PresetChoice], OPTION_FLAG_NONE)
         else
            OIDPresetRates = AddMenuOption("Barter Presets", PresetList[PresetChoice], OPTION_FLAG_DISABLED)
         endif
         OIDUseBarterRates = AddToggleOption("Use Custom Barter Settings", UseBarterSettings.getValueInt())
         AddEmptyOption()
         BarterMinVal = Game.GetGameSettingFloat("fBarterMin")
         BarterMaxVal = Game.GetGameSettingFloat("fBarterMax")
         AddHeaderOption("Settings")

     endif
     SetCursorPosition(1) ;start right-hand column
     if TVModStatus.getValue() == 0
        OIDModStatus = AddTextOption("Start Mod", "")
     else
        OIDModStatus = AddTextOption("Stop Mod", "")
     endif
endEvent


event OnOptionMenuOpen(int option)
   string page = CurrentPage
   if option == OIDPresetRates
      SetMenuDialogOptions(PresetList)
      SetMenuDialogStartIndex(PresetChoice)
      SetMenuDialogDefaultIndex(1)
   endif
endEvent

event OnOptionMenuAccept(int option, int index)
   string page = CurrentPage
   if option == OIDPresetRates
      PresetChoice = index
      SetMenuOptionValue(OIDPresetRates, PresetList[PresetChoice])
      if PresetChoice == 1 ;Easy
          ;stuff...
      elseif PresetChoice == 2 ;Medium
          ;stuff...
      elseif PresetChoice == 3 ;Difficult
          ;stuff...
      elseif PresetChoice == 4 ;Hardcore
          ;stuff...
      endif
      ForcePageReset()
   endif
endEvent
Link to comment
Share on other sites

I put array definitions for menus into the MCM OnConfigRegister() event. Otherwise my code--which works--looks very similar to yours; here are the relevant snippets:

blahblahblahsetup
 
string[] aCapacities
int iCapacityIndex
int OIDiSackCapacity
 
event OnConfigRegister()
 aCapacities = new string[5]
 aCapacities[0] = "50"
 aCapacities[1] = "100"
 aCapacities[2] = "200"
 aCapacities[3] = "300"
 aCapacities[4] = "Unlimited"
 iCapacityIndex = 4
endevent
 
event OnPageReset(string page)
 blahblahblah
 OIDiSackCapacity = AddMenuOption("Treasure Sack Capacity", aCapacities[iCapacityIndex])
endEvent
 
event OnOptionMenuOpen(int option)
 if (option == OIDiSackCapacity)
  SetMenuDialogOptions(aCapacities)
  SetMenuDialogStartIndex(iCapacityIndex)
  SetMenuDialogDefaultIndex(4)
 endIf
endEvent
 
event OnOptionMenuAccept(int option, int index)
 if (option == OIDiSackCapacity)
  if index != iCapacityIndex
   SetMenuOptionValue(OIDiSackCapacity, aCapacities[index])
   iCapacityIndex = index
  endif
 endIf
endEvent

If things aren't working, make sure you are working from a save made before you first initialized the script. Or console start/stop the quest that the script is attached to--that can sometimes force the MCM to update.

Link to comment
Share on other sites

Thanks for the suggestion. Unfortunately, that didn't work either. I am working off of a previous save from before the mod was activated, but I tried stopping & starting the quest through the console anyway...still no luck.

Link to comment
Share on other sites

  • 8 months later...

Thanks for the suggestion. Unfortunately, that didn't work either. I am working off of a previous save from before the mod was activated, but I tried stopping & starting the quest through the console anyway...still no luck.

 

Hey, I encountered this issue too, and problem is in this part of code

 

PresetList[0] = "None"

 

MCM is allergic to strings containing "None", I used "None " instead and that works.

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...