the Sim Settlements forums!

Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

Help with MCM

diziet

Active Member
Messages
541
Hi, I posted this question to the Fallout4 modders forum on nexus, I got replies but no solutions, so I thought I would try here, my complete original posted is posted below:

Hi, I'm tring to follow the example here:
https://github.com/N...i/Control-Types
of a button, this is my first attempt at an MCM menu in F4.

This is my config.json and it does show the two buttons:

Code:
{
  "modName": "dz_no_attacks",      
  "displayName": "MCM for No Settlement Attacks",
  "minMcmVersion": 2,                      
  "content": [
  {
   "text": "Demo Button",
   "type": "button",
   "help": "This button disallows attacks at abernathy.",
   "action": {
   "type": "CallFunction",
   "form": "dz_no_attacks.esp|800",  
   "function": "dz_disallow_attacks",
   "params": []
      }
  },
  {
    "text": "Another Demo Button",
    "type": "button",
    "help": "Displays a messagebox via a CallGlobalFunction action.",
    "action": {
   "type": "CallGlobalFunction",
   "script": "Debug",
   "function": "MessageBox",
   "params": ["Hello world!"]
     }
  }
]
}
Now at the moment the call to the global debug function works, but I cannot get this function to run from the top button in my test script:

Code:
Scriptname dz_no_attacks_quest_script Extends Quest

Function dz_disallow_attacks()
debug.trace("value is ")
debug.messagebox("new value is ")
EndFunction

there is neither a message box in game, or a trace in the Papyrus.log.0 file.
The script is attached to a quest, and that quest shows up in the console so I assume it is running?

diziet

p.s. as I replied on the nexus forum, the formid is indeed 8000:D
 
You may want to add "pluginRequirements": ["dz_no_attacks.esp"], after "minMcmVersion": 2, (not a solution to your issue but will remove the entry if the plugin is removed from the LO)

For your first button "params": [] is not needed. I would try deleting the line. Also, IIRC, if you want to pass none, it should be "params": [""] Edit: "params": [] is the correct way to pass none. I found that if you have the double quotes, you get an error in the papyrus log saying you passed too many params. The name/value pair can be removed altogether.

You can get the quest status by using the console command sqv {quest EDID} It will show attached scripts + vars + script state, IsRunning and current stage.

Also note: if your quest isn't flagged run once, all vars/properties will be reset to the default values when the quest is started.
 
Last edited:
Ok, thanks for this. I have tried without the params line but wasn't sure if it was needed, I will try with the proper way to pass none. Also I will use that command to check in the console.

diziet
 
Last edited:
I managed to fix things by accident, I deleted the 's' in attacks to deliberately make the function name wrong to see what error I might get. When I put the 's' back it suddenly started working!

But now I wonder if anyone knows how to get the MCM to reflect a value that has been changed by a function. My MCM menu will toggle a Bool True/False, I want the button to either accurately show the actual state or to have the MCM menu refresh a text entry to do that. A switcher button will just go from On to Off, but that just means the menu config.json is properly formatted, a user could assume that On = True and Off = False, but if things got switched around, how would they know?
in Skyrim you can have a function check for the condition you want and then in the MCM script directly alter the toggle to be empty or filled, because the MCM menu is the script. I don't know how to get the Fallout 4 script to alter the MCM menu as opposed to the other way around.

diziet
 
Edit: After learning a lot more, I'll update this for future reference. For the above bool use case, this control would be more appropriate.
Code:
{
    "id": "bSomeBool:Main",    // ini setting name | ini section, this is in settings.ini in /MCM/myMod/settings.ini
    "text": "Demo Button",
    "type": "switcher",
    "help": "Stuff happens when you click this.",
    "valueOptions": {
        "sourceType": "ModSettingBool"    // tells MCM to get mod setting value defined in id tag
    },
    "action": {
        "type": "CallFunction",
        "form": "myMod.esp|myFormIDinHEX", 
        "function": "FunctionOnMyScriptToCall",
        "params": []    // params my function expects, specify with {b}, {i}, {f} and {s} for bool, int, float, string - example "{b}{value}" would pass the switcher value as a bool to the script function call
                        // you can pass the new value "{b}{value}" with the function call to update things in your script when the setting is changed.
    }
}
You could toggle a global variable, MCM will display based on its current value. You would have to register for the MCM even when the player exits the MCM menu so your script can update based on the value of the global.
Code:
    "valueOptions": {
        "sourceType": "GlobalValue",
        "sourceForm": "myMod.esp|FormID HEX"
Of you could reference a script property directly.
Code:
    "valueOptions": {
        "sourceType": "PropertyValueBool",
        "sourceForm": "myMod.esp|QuestFormID HEX",
        "propertyName": "myBoolProperty"
I do not know if MCM can use full properties. If it can you could do something like this:
Code:
ScriptName someQuestScript extends Quest

bool myBoolPropertyLocal = false
bool Property myBoolProperty
    bool Function Get()
        return myBoolPropertyLocal
    EndFunction
  
    Function Set(bool abValue)
        myBoolPropertyLocal = abValue
        ; do stuff on toggle of property as required
        ; maybe implement a timer to prevent spamming issues
    EndFunction
EndProperty
 
Last edited:
You decipher any secrets? As I said in the other thread, I'm starting to create my own MCM menu and even using WSFW and SS2 as templates, I'm feeling a little overwhelmed. (json is not my friend...)

So far, I have managed to figure out how to configure hotkey options and call script functions. I have yet to get into the property set/get monkey business, but I do know there has been some discussion about it recently in the Nexus Author's Discord.
 
All I've worked out so far is what you told me about a switcher displaying on/off depending on the value of the sourcetype. Rather than register for a MCM event I have used a source type of a boolean property in my script and the script uses MCM.Refresh(). This wasn't a deliberate choice, just how it worked out. I have recently realised that since my menu sourcetypes are booleans in my script that are set by the values of booleans from vanilla scripts, I should be using as sourcetype the vanilla properties directly - then no need to call a function from my script, the switcher will change the vanilla boolean for me! But my menu seems to work, so I'm leaving it for now:)
I'm still trying to get to grips with hiding/displaying pages, see my other post on these forums.

diziet
 
I just released my Rename Anything Enhanced mod I've been working on. Being able to hide the whole MCM menu would be great for when a condition is met instead of just disabling the function in the script.

I spent a bunch of time yesterday flexing my google-fu to find a great nothing. It seems the options are join the MCM discord server and pray someone is willing to hold my hand or download a bunch of mods with an MCM menu and dissect it.
 
There's an MCM discord server? I didn't know it was being worked on between F4SE releases (few and far between these days).:)

diziet
 
Also, IIRC, if you want to pass none, it should be "params": [""]
I have learned this is incorrect. To pass none it would be "params": [] or remove the name/value pair altogether.
There's an MCM discord server?
That's what I was told.
You could also try asking in the MCM Discord. Though they're not generally super speedy to answer, and they tend not to hand hold. So the answer you may get can be terse.
I got scared by the lack of hand holding so I haven't looked into it.

Did you download the MCM_Demo mod? Its kinda nice to see the concepts in action. I've been playing with it a little and I think I'm starting to understand the display conditions a little. The name "id" seems to be used to point to a setting in the ini file you can define. That's the magic that allows settings to persist between saves. I still haven't figured out how you could reliably sync a script property / global variable to the MCM ini setting... yet.
 
I haven't used the settings.ini for my mod. I did find by experiment that the hidden switchers I used had to be in the page content for the items they were controlling (which make sense) and that seemingly as a result you could reuse condition numbers in a different page - though I didn't, just to be sure!
What I've done regarding pages that reference uninstalled stuff is use the {ONLY:) thing i.e.
{
"text": "$info1",
"type": "text",
"groupCondition": {"ONLY":[]},
"html": "true"
},

if every other item on that page has a groupCondition, then when none are satisfied the $info1 token is substituted.
In my case it so happens that the groupconditions are all based on some esm/esp existing, so if none of them are I get the $info1 text which explains that nothing supported is installed.

diziet
 
Adding nexus threads for reference.
 
I think you are onto something about NP++. I finally got it to get/set a mod setting value. Once I re-entered the ID tags, all was good. There must be some kind of encoding issue. I'll use VS Code for the rest and see if I have the same issue. arg... to spend so much time thinking my syntax sucked to find out it was my editor......... This is on par with the power of Todd. ;)

Edit: Since I switched to using VS Code, (MS Visual Studio Code) I have not had the issue of MCM failing to recognize my tag. (even if I did actually spell it correctly) This issue was most prevalent when copy/pasting from the MCM wiki of MCM Demo config.json. So I would conclude that MCM doesn't like the raw format NP++ encodes the created file with. Even stranger, just opening and saving a json edited in NP++ with VS Code will fix this issue.
 
Last edited:
20220221072406_1.jpg
Nice, the settings persist between saves.
 
New finding:
a defined groupControl is only valid for the "content" tag is was defined in. I had to define them for each page to work properly.

Also, VS Code works great. It even tells you if you forgot a , somewhere. :)

Is there a logical NOT operator? I only see mention of AND/OR so I assume not. :(
 
Here's one, using the tokenisation and a file in /data/interface/translations I found that the token $Sanctuary was always replaced with 'Sanctuary' despite the actual string being much longer. As soon as I swapped the upper case 's' to lower case i.e. $sanctuary, everything worked. I had no such problems with $Somerville or $Spectacle :)

Also, have you seen the document:
https://github.com/Neanka/MCM_0.1_AS3/blob/master/KNOW ISSUES.txt ?
clearly implies hiding pages, but doesn't say how :)

diziet
 
clearly implies hiding pages, but doesn't say how
It also says 'todo' :( I would guess its not implemented.
As soon as I swapped the upper case 's' to lower case i.e. $sanctuary, everything worked.
I highly suspect there's an issue with the language encoding in NP++. Since I started using VS Code for this, I have not had any errors with my id tags not being paired properly when testing the menu. Hopefully I'll have time today to re-read this thread from the beginning and try a few ideas I have.

Also, thanks for the link! I didn't even think of looking for a readme on the git repo... smh Finally, some examples on how to use the TextInput* tags. :)
 
I so wish there was a "MCM for Dummies" ;) Heck, even a list of valid tag options for each control would be nice.

It seems like you can point a control to a mod setting for valueOption and call a script function with action. :scratchhead Hopefully it doen't snow today and I can look into this a little. :)

Edit: I have edited a few posts in this thread updating invalid statements and new things I have discovered. Hopefully at the end of this journey, I'll be able to put together a MCM for dummies article.
 
Last edited:
Top