### Papyrus API: String Settings Management Source: https://context7.com/reg2k/f4mcm/llms.txt This section illustrates how to manage string settings within the MCM. It provides functions to retrieve and store string values, such as preset names. The example showcases saving and loading game presets, including associated numerical and boolean settings, and applying them to the game. It also includes notifications for user feedback. ```papyrus ; Read and write string mod settings string Function GetPresetName(string modName) global ; Returns string value or empty string if not found return MCM.GetModSettingString(modName, "sPresetName:General") EndFunction Function SavePreset(string modName, string presetName) global MCM.SetModSettingString(modName, "sPresetName:General", presetName) EndFunction ; Complete example for preset system Scriptname PresetManagerScript extends Quest string Property ModName = "PresetMod" AutoReadOnly Function SaveCurrentPreset(string presetName) ; Save preset name MCM.SetModSettingString(ModName, "sActivePreset:Presets", presetName) ; Save associated settings MCM.SetModSettingInt(ModName, "iDamage:Presets", 150) MCM.SetModSettingFloat(ModName, "fSpeed:Presets", 1.5) MCM.SetModSettingBool(ModName, "bHardcore:Presets", true) Debug.Notification("Preset saved: " + presetName) EndFunction Function LoadPreset() string activePreset = MCM.GetModSettingString(ModName, "sActivePreset:Presets") if activePreset != "" ; Load preset settings int damage = MCM.GetModSettingInt(ModName, "iDamage:Presets") float speed = MCM.GetModSettingFloat(ModName, "fSpeed:Presets") bool hardcore = MCM.GetModSettingBool(ModName, "bHardcore:Presets") Debug.Notification("Loaded preset: " + activePreset) ApplyPresetSettings(damage, speed, hardcore) else Debug.Trace("No preset found") endif EndFunction Function ApplyPresetSettings(int dmg, float spd, bool hc) ; Apply loaded settings to game Game.SetGameSettingInt("iDamageAmount", dmg) EndFunction ``` -------------------------------- ### Check F4MCM Installation and Version (Papyrus) Source: https://context7.com/reg2k/f4mcm/llms.txt Checks if the Fallout 4 Mod Configuration Menu (F4MCM) plugin is installed and retrieves its version information. This is crucial for ensuring compatibility before attempting to use MCM features. The `IsModConfigInstalled` function returns a boolean, and `GetMCMVersion` returns an integer code representing the version. ```papyrus ; Check if MCM is installed and get version information bool Function IsModConfigInstalled() global return MCM.IsInstalled() EndFunction int Function GetMCMVersion() global return MCM.GetVersionCode() EndFunction ; Example usage in a mod's initialization Event OnInit() if MCM.IsInstalled() Debug.Trace("MCM is installed, version: " + MCM.GetVersionCode()) ; Version code 9 = v1.40 else Debug.MessageBox("This mod requires Mod Configuration Menu to be installed.") endif EndEvent ``` -------------------------------- ### Papyrus API: Float Settings Management Source: https://context7.com/reg2k/f4mcm/llms.txt This snippet demonstrates how to read and write floating-point settings for mods using the MCM API. It includes functions to get and set float values, with an example of applying movement-related settings like speed and jump height to the player. It handles potential errors by returning a default value if a setting is not found and clamps values within a specified range. ```papyrus ; Read and write floating-point mod settings float Function GetSpeedMultiplier(string modName) global ; Returns float value from settings ; Returns -1.0 if setting not found return MCM.GetModSettingFloat(modName, "fSpeedMultiplier:Movement") EndFunction Function SetSpeedMultiplier(string modName, float multiplier) global MCM.SetModSettingFloat(modName, "fSpeedMultiplier:Movement", multiplier) EndFunction ; Complete example for movement mod Scriptname MovementModScript extends ActiveMagicEffect string Property ModName = "MovementEnhancer" AutoReadOnly Event OnEffectStart(Actor akTarget, Actor akCaster) ; Read all movement-related settings float speedMult = MCM.GetModSettingFloat(ModName, "fSpeedMultiplier:Movement") float jumpHeight = MCM.GetModSettingFloat(ModName, "fJumpHeight:Movement") float sprintCost = MCM.GetModSettingFloat(ModName, "fSprintCost:Movement") ; Apply to player if akTarget == Game.GetPlayer() akTarget.SetActorValue("SpeedMult", speedMult) ; Values are persisted in MCM settings file endif EndEvent Function AdjustSpeed(float delta) float currentSpeed = MCM.GetModSettingFloat(ModName, "fSpeedMultiplier:Movement") float newSpeed = currentSpeed + delta ; Clamp between 0.5 and 2.0 if newSpeed < 0.5 newSpeed = 0.5 elseif newSpeed > 2.0 newSpeed = 2.0 endif MCM.SetModSettingFloat(ModName, "fSpeedMultiplier:Movement", newSpeed) EndFunction ``` -------------------------------- ### MCM Scaleform Keybind Management Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This set of MCM Scaleform functions facilitates the management of keybinds and hotkeys within the game. It includes functions to check if a plugin is installed, retrieve all keybinds or specific keybinds, set new keybinds, clear existing ones, and remap keys. ```Scaleform IsPluginInstalled(pluginName:String):Boolean GetAllKeybinds():Object GetKeybind(keybindName:String):Object SetKeybind(keybindName:String, key:String, mod:String, action:String, ...args):Boolean ClearKeybind(keybindName:String):Boolean RemapKeybind(oldKeybindName:String, newKeybindName:String):Boolean ``` -------------------------------- ### Papyrus API: Menu Refresh Source: https://context7.com/reg2k/f4mcm/llms.txt This snippet details how to force the MCM menu to refresh and reload settings, which is crucial for dynamic updates. It shows a `RefreshMenu()` function and provides examples of how to use it in conjunction with setting changes, such as when a player levels up or when settings are modified externally. This ensures the menu accurately reflects the current game state. ```papyrus ; Force MCM menu to refresh and reload settings Function RefreshMCMMenu() global MCM.RefreshMenu() EndFunction ; Complete example for dynamic menu updates Scriptname DynamicMenuScript extends Quest string Property ModName = "DynamicMod" AutoReadOnly Function OnExternalSettingChange() ; When settings change from outside MCM (e.g., console command) ; Update the internal settings MCM.SetModSettingInt(ModName, "iLevel:Progress", Game.GetPlayer().GetLevel()) ; Force MCM menu to refresh if it's currently open MCM.RefreshMenu() Debug.Trace("MCM menu refreshed with new settings") EndFunction Event OnPlayerLevelUp(int newLevel) ; Update level-dependent settings MCM.SetModSettingInt(ModName, "iPlayerLevel:Stats", newLevel) ; Refresh menu to show updated level MCM.RefreshMenu() EndEvent Function UpdateDynamicOptions(string[] newOptions) ; Update string option that shows in menu string optionList = "" int i = 0 while i < newOptions.Length optionList += newOptions[i] if i < newOptions.Length - 1 optionList += "," endif i += 1 endwhile MCM.SetModSettingString(ModName, "sAvailableOptions:Dynamic", optionList) MCM.RefreshMenu() EndFunction ``` -------------------------------- ### MCM Scaleform Mod Setting Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt These MCM Scaleform functions provide an interface for getting and setting integer, boolean, float, and string values for mod settings. They allow MCM menus to interact with and manage mod-specific configurations. ```Scaleform GetModSettingInt(settingName:String):int SetModSettingInt(settingName:String, value:int):void GetModSettingBool(settingName:String):Boolean SetModSettingBool(settingName:String, value:Boolean):void GetModSettingFloat(settingName:String):float SetModSettingFloat(settingName:String, value:float):void GetModSettingString(settingName:String):String SetModSettingString(settingName:String, value:String):void ``` -------------------------------- ### SettingStore C++ API for MCM Plugin Development Source: https://context7.com/reg2k/f4mcm/llms.txt This C++ API allows plugin developers to interact with the SettingStore for reading and writing mod settings. It handles persistence to .ini files and provides methods for integer, boolean, float, and string settings. Dependencies include the SettingStore header. ```cpp // Internal C++ API for plugin developers extending MCM #include "SettingStore.h" // Get singleton instance SettingStore& store = SettingStore::GetInstance(); // Read settings SInt32 intValue = store.GetModSettingInt("MyMod", "iSetting:Section"); bool boolValue = store.GetModSettingBool("MyMod", "bEnabled:Section"); float floatValue = store.GetModSettingFloat("MyMod", "fMultiplier:Section"); char* stringValue = store.GetModSettingString("MyMod", "sName:Section"); // Write settings (automatically saved to Data\MCM\Settings\MyMod.ini) store.SetModSettingInt("MyMod", "iSetting:Section", 42); store.SetModSettingBool("MyMod", "bEnabled:Section", true); store.SetModSettingFloat("MyMod", "fMultiplier:Section", 1.5f); store.SetModSettingString("MyMod", "sName:Section", "Value"); // Complete example: Combat difficulty manager class CombatDifficultyManager { private: std::string modName = "CombatMod"; SettingStore& settings = SettingStore::GetInstance(); public: void ApplyDifficultySettings() { // Read all combat settings SInt32 difficulty = settings.GetModSettingInt(modName, "iDifficulty:Combat"); float damageOut = settings.GetModSettingFloat(modName, "fDamageToEnemies:Combat"); float damageIn = settings.GetModSettingFloat(modName, "fDamageFromEnemies:Combat"); bool hardcoreMode = settings.GetModSettingBool(modName, "bHardcoreMode:Combat"); // Apply settings to game if (difficulty >= 1 && difficulty <= 10) { // Scale damage based on difficulty float scaleFactor = 0.5f + (difficulty * 0.15f); ApplyDamageScale(damageOut * scaleFactor, damageIn / scaleFactor); } if (hardcoreMode) { EnableHardcoreFeatures(); } } void SavePlayerPreference(const char* preferenceName, float value) { // Save dynamic preference std::string settingKey = std::string("f") + preferenceName + ":Preferences"; settings.SetModSettingFloat(modName, settingKey, value); } void LoadSettingsFromDisk() { // Trigger full settings reload settings.ReadSettings(); } }; // Register with F4SE plugin void OnF4SEMessage(F4SEMessagingInterface::Message* msg) { if (msg->type == F4SEMessagingInterface::kMessage_GameLoaded) { CombatDifficultyManager manager; manager.ApplyDifficultySettings(); } } ``` -------------------------------- ### Build Configuration Source: https://context7.com/reg2k/f4mcm/llms.txt Build script for creating the F4SE plugin DLL. Specifies build directories, platform toolset, and F4SE revision. ```APIDOC ## Build Configuration ### Description Build script (`build.py`) for compiling the F4SE plugin (`.dll`). Defines build output location, source directory, and F4SE version. ### Method Python script execution. ### Command ```bash python build.py ``` ### Parameters (Internal to script) - `BUILD_DIR`: Directory for build artifacts (e.g., 'build'). - `PROJECT_DIR`: Source code directory (e.g., 'src'). - `PLATFORM_TOOLSET`: Visual Studio platform toolset (e.g., 'v140'). - `F4SE_REVISION`: F4SE version tag (e.g., 'tags/v0.6.18'). ### Output - `f4mcm.dll`: The compiled plugin, to be placed in `Fallout4\Data\F4SE\Plugins\`. ### Required Folder Structure for Mod Development - `Fallout4\Data\MCM\` (created automatically) - `Fallout4\Data\MCM\Config\ModName\` (created by mod developers) - `Fallout4\Data\MCM\Settings\` (created automatically) ``` -------------------------------- ### SettingStore C++ API Source: https://context7.com/reg2k/f4mcm/llms.txt Internal C++ API for plugin developers extending MCM. This API allows developers to read and write mod settings, which are automatically saved to a .ini file. ```APIDOC ## SettingStore C++ API ### Description Internal C++ API for plugin developers extending MCM. Allows reading and writing of mod settings. ### Methods #### Reading Settings - `SInt32 GetModSettingInt(const char* modName, const char* settingName)`: Reads an integer setting. - `bool GetModSettingBool(const char* modName, const char* settingName)`: Reads a boolean setting. - `float GetModSettingFloat(const char* modName, const char* settingName)`: Reads a float setting. - `char* GetModSettingString(const char* modName, const char* settingName)`: Reads a string setting. #### Writing Settings - `void SetModSettingInt(const char* modName, const char* settingName, SInt32 value)`: Writes an integer setting. Saved to `Data\MCM\Settings\.ini`. - `void SetModSettingBool(const char* modName, const char* settingName, bool value)`: Writes a boolean setting. - `void SetModSettingFloat(const char* modName, const char* settingName, float value)`: Writes a float setting. - `void SetModSettingString(const char* modName, const char* settingName, const char* value)`: Writes a string setting. #### Other - `SettingStore& GetInstance()`: Gets the singleton instance of SettingStore. - `void ReadSettings()`: Forces a reload of all settings from disk. ### Example Usage ```cpp #include "SettingStore.h" SettingStore& store = SettingStore::GetInstance(); // Read settings SInt32 intValue = store.GetModSettingInt("MyMod", "iSetting:Section"); // Write settings store.SetModSettingInt("MyMod", "iSetting:Section", 42); ``` ``` -------------------------------- ### F4MCM Plugin Build Configuration Script Source: https://context7.com/reg2k/f4mcm/llms.txt This Python script configures and builds the F4MCM plugin. It specifies build directories, platform toolset, and F4SE revision. The script executes build tools and reports the success or failure of the build process. The output is an f4mcm.dll file. ```python # build.py - Build the F4SE plugin import os, sys # Configuration BUILD_DIR = 'build' PROJECT_DIR = 'src' PLATFORM_TOOLSET = 'v140' F4SE_REVISION = 'tags/v0.6.18' # Run build tools buildOK = os.system('python tools/build-tools/build_plugin.py "{}" "{}" "{}" "{}"' .format(BUILD_DIR, PROJECT_DIR, PLATFORM_TOOLSET, F4SE_REVISION)) # Report result sys.exit(buildOK) # Build produces f4mcm.dll which should be placed in: # Fallout4\Data\F4SE\Plugins\f4mcm.dll # Required folder structure: # Fallout4\Data\MCM\ (created automatically) # Fallout4\Data\MCM\Config\ModName\ (mod developers create) # Fallout4\Data\MCM\Settings\ (created automatically) ``` -------------------------------- ### F4MCM Overview Source: https://context7.com/reg2k/f4mcm/llms.txt General overview of the F4MCM plugin's purpose and functionality, including its role in mod configuration and its keybind system. ```APIDOC ## F4MCM Plugin Overview ### Description F4MCM serves as the central configuration manager for Fallout 4 mods, eliminating manual file editing. It provides APIs for mod developers to manage settings and integrates a keybind system for custom hotkeys. ### Functionality - **Unified Configuration**: Allows mods to define configuration options accessible through a user-friendly interface. - **Persistence**: Automatically saves and loads mod settings across game sessions. - **Type Conversion & Compatibility**: Handles various data types and ensures cross-compatibility. - **Keybind System**: Enables mods to register custom hotkeys with conflict detection. Users can remap these keybinds through the MCM interface. - **Keybind Actions**: Supports complex actions for keybinds, including Papyrus function calls, console commands, and custom event dispatching. ### Developer Integration - **Configuration Files**: Mod developers create JSON configuration files within the MCM directory structure. - **Access APIs**: Settings can be accessed via: - **Papyrus API**: For use in gameplay scripts. - **Scaleform API**: For UI elements. - **Keybind Registration**: Mods can register keybinds to allow user customization. ``` -------------------------------- ### Define Keybinds using JSON Format Source: https://context7.com/reg2k/f4mcm/llms.txt JSON files are used to define available keybinds for mods, specifying their IDs, descriptions, types, and associated callback functions or console commands. User keybind assignments are saved separately in a similar JSON format. ```json // Data\MCM\Config\MyMod\keybinds.json - Define available keybinds { "quickSave": { "id": "quickSave", "desc": "Quick Save Game", "type": 2, "callbackName": "OnQuickSave", "scriptName": "MyModScript" }, "toggleUI": { "id": "toggleUI", "desc": "Toggle UI Visibility", "type": 0, "targetFormID": "0x00000D62", "callbackName": "ToggleUI" }, "openInventory": { "id": "openInventory", "desc": "Open Inventory", "type": 2, "callbackName": "bat openinventory", "scriptName": "", "params": [] } } // Type values: // 0 = CallFunction (call function on quest/form) // 1 = CallGlobalFunction (call global Papyrus function) // 2 = RunConsoleCommand (execute console command) // 3 = SendEvent (send OnControlDown/OnControlUp events) // User keybind assignments saved to Data\MCM\Settings\Keybinds.json // Format: {"keycode": 33, "modifiers": 2, "modName": "MyMod", "keybindID": "quickSave"} // modifiers: 1=Shift, 2=Ctrl, 4=Alt (can combine: 3=Shift+Ctrl) ``` -------------------------------- ### MCM Scaleform Keybind Action Types Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This section details the different types of actions that can be assigned to keybinds in MCM. It includes calling global functions, running console commands, and sending events to target forms. Support for Control and Alt modifiers is also included. ```Scaleform // Keybind action types: CallGlobalFunction RunConsoleCommand SendEvent (sends OnControlDown/OnControlUp event to target form) ``` -------------------------------- ### MCM Scaleform StartKeyCapture and StopKeyCapture Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt These MCM Scaleform functions are used to initiate and terminate key capture for specific events. StartKeyCapture begins listening for key presses, while StopKeyCapture ends this process. Note: These were removed in later versions. ```Scaleform StartKeyCapture StopKeyCapture ``` -------------------------------- ### MCM Callbacks Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This section details the callback functions triggered by MCM events. ```APIDOC ## MCM Callbacks This section details the callback functions triggered by MCM events. ### ProcessKeyEvent - **Description**: Callback function that is triggered when a key event occurs. - **Method**: Scaleform Callback - **Parameters**: - `keyCode` (int) - The code of the key that was pressed or released. - `isDown` (Boolean) - True if the key was pressed down, false if it was released. ### ProcessUserEvent - **Description**: Callback function that is triggered when a user event occurs. - **Method**: Scaleform Callback - **Parameters**: - `controlName` (String) - The name of the control that triggered the event. - `isDown` (Boolean) - True if the control is down, false otherwise. - `deviceType` (int) - The type of device that triggered the event (e.g., mouse, gamepad). ### OnMCMOpen - **Description**: Callback function that is triggered when the MCM menu is opened. - **Method**: Scaleform Callback ### OnMCMClose - **Description**: Callback function that is triggered when the MCM menu is closed. - **Method**: Scaleform Callback ``` -------------------------------- ### Scaleform Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This section details the Scaleform functions available in the MCM API for interacting with mods and game settings. ```APIDOC ## Scaleform Functions This section details the Scaleform functions available in the MCM API for interacting with mods and game settings. ### GetPropertyValue - **Description**: Retrieves the value of a specific property for a given form identifier. - **Method**: Scaleform - **Parameters**: - `formIdentifier` (String) - The identifier of the form. - `propertyName` (String) - The name of the property to retrieve. - **Returns**: `*` - The value of the property. ### SetPropertyValue - **Description**: Sets the value of a specific property for a given form identifier. - **Method**: Scaleform - **Parameters**: - `formIdentifier` (String) - The identifier of the form. - `propertyName` (String) - The name of the property to set. - `newValue` (*) - The new value for the property. - **Returns**: `Boolean` - True if the value was set successfully, false otherwise. ### GetConfigList - **Description**: Retrieves a list of configuration files. - **Method**: Scaleform - **Parameters**: - `fullPath` (Boolean) - Optional. If true, returns full paths. Defaults to false. - `filename` (String) - Optional. Specifies a filename to retrieve. Defaults to "config.json". - **Returns**: `Array` - A list of configuration files. ### GetMCMVersionCode - **Description**: Retrieves the version code of the MCM. - **Method**: Scaleform - **Returns**: `int` - The MCM version code. ### GetMCMVersionString - **Description**: Retrieves the version string of the MCM. - **Method**: Scaleform - **Returns**: `String` - The MCM version string. ### SetKeybind - **Description**: Sets a keybind for a specific action. - **Method**: Scaleform - **Parameters**: - `actionType` (String) - The type of action (e.g., "CallGlobalFunction", "RunConsoleCommand", "SendEvent"). - `key` (String) - The key to bind. - `modifiers` (Array) - Optional. Modifiers for the keybind (e.g., "Control", "Alt"). - `target` (Object) - Optional. The target for the action. - `functionName` (String) - Optional. The name of the function to call. - `parameters` (Array<*>) - Optional. Parameters for the function. - **Returns**: `Boolean` - True if the keybind was set successfully, false otherwise. ### ClearKeybind - **Description**: Clears a previously set keybind. - **Method**: Scaleform - **Parameters**: - `key` (String) - The key of the keybind to clear. - **Returns**: `Boolean` - True if the keybind was cleared successfully, false otherwise. ### RemapKeybind - **Description**: Remaps an existing keybind to a new key. - **Method**: Scaleform - **Parameters**: - `oldKey` (String) - The original key of the keybind. - `newKey` (String) - The new key to remap to. - **Returns**: `Boolean` - True if the keybind was remapped successfully, false otherwise. ### IsPluginInstalled - **Description**: Checks if a specific plugin is installed. - **Method**: Scaleform - **Parameters**: - `pluginName` (String) - The name of the plugin to check. - **Returns**: `Boolean` - True if the plugin is installed, false otherwise. ### GetAllKeybinds - **Description**: Retrieves all currently registered keybinds. - **Method**: Scaleform - **Returns**: `Object` - An object containing all keybinds. ### GetKeybind - **Description**: Retrieves information about a specific keybind. - **Method**: Scaleform - **Parameters**: - `key` (String) - The key of the keybind to retrieve. - **Returns**: `Object` - An object containing information about the keybind. ### StartKeyCapture - **Description**: Starts capturing key presses. - **Method**: Scaleform ### StopKeyCapture - **Description**: Stops capturing key presses. - **Method**: Scaleform ### GetGlobalValue - **Description**: Retrieves the value of a global variable. - **Method**: Scaleform - **Parameters**: - `variableName` (String) - The name of the global variable. - **Returns**: `*` - The value of the global variable. ### SetGlobalValue - **Description**: Sets the value of a global variable. - **Method**: Scaleform - **Parameters**: - `variableName` (String) - The name of the global variable. - `newValue` (*) - The new value for the global variable. - **Returns**: `Boolean` - True if the value was set successfully, false otherwise. ### CallQuestFunction - **Description**: Calls a function on a quest or other form. - **Method**: Scaleform - **Parameters**: - `questName` (String) - The name of the quest or form. - `functionName` (String) - The name of the function to call. - `parameters` (Array<*>) - Optional. Parameters for the function. - **Returns**: `*` - The return value of the function. ### CallGlobalFunction - **Description**: Calls a global function. - **Method**: Scaleform - **Parameters**: - `functionName` (String) - The name of the global function to call. - `parameters` (Array<*>) - Optional. Parameters for the function. - **Returns**: `*` - The return value of the function. ### OnMCMOpen - **Description**: Callback function that is triggered when the MCM menu is opened. - **Method**: Scaleform Callback ### OnMCMClose - **Description**: Callback function that is triggered when the MCM menu is closed. - **Method**: Scaleform Callback ### Get/SetModSettingInt - **Description**: Gets or sets an integer mod setting. - **Method**: Scaleform - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (int) - Optional. The new integer value to set. - **Returns**: `int` - The current or new value of the mod setting. ### Get/SetModSettingBool - **Description**: Gets or sets a boolean mod setting. - **Method**: Scaleform - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (Boolean) - Optional. The new boolean value to set. - **Returns**: `Boolean` - The current or new value of the mod setting. ### Get/SetModSettingFloat - **Description**: Gets or sets a float mod setting. - **Method**: Scaleform - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (Float) - Optional. The new float value to set. - **Returns**: `Float` - The current or new value of the mod setting. ### Get/SetModSettingString - **Description**: Gets or sets a string mod setting. - **Method**: Scaleform - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (String) - Optional. The new string value to set. - **Returns**: `String` - The current or new value of the mod setting. ### DisableMenuInput - **Description**: Disables input for the menu. - **Method**: Scaleform ### RefreshMenu - **Description**: Refreshes the MCM menu. - **Method**: Papyrus Function ``` -------------------------------- ### Access Mod Settings with Scaleform API (ActionScript) Source: https://context7.com/reg2k/f4mcm/llms.txt ActionScript code is used within the Scaleform UI to interact with the Mod Configuration Menu (MCM). It allows reading and writing mod settings, enabling dynamic configuration of mod behavior through the in-game UI. ```actionscript // JavaScript/ActionScript for Scaleform UI // Get and set mod settings from MCM menu interface function loadModSettings(modName) { // Read integer setting var difficulty = root1.f4se.plugins.MCM.GetModSettingInt(modName, "iDifficulty:Gameplay"); // Read boolean setting var enabled = root1.f4se.plugins.MCM.GetModSettingBool(modName, "bEnabled:General"); // Read float setting var multiplier = root1.f4se.plugins.MCM.GetModSettingFloat(modName, "fDamageMultiplier:Gameplay"); // Read string setting var presetName = root1.f4se.plugins.MCM.GetModSettingString(modName, "sPresetName:General"); return { difficulty: difficulty, enabled: enabled, multiplier: multiplier, preset: presetName }; } function saveModSettings(modName, settings) { // Write integer setting root1.f4se.plugins.MCM.SetModSettingInt(modName, "iDifficulty:Gameplay", settings.difficulty); // Write boolean setting root1.f4se.plugins.MCM.SetModSettingBool(modName, "bEnabled:General", settings.enabled); // Write float setting root1.f4se.plugins.MCM.SetModSettingFloat(modName, "fDamageMultiplier:Gameplay", settings.multiplier); // Write string setting root1.f4se.plugins.MCM.SetModSettingString(modName, "sPresetName:General", settings.preset); } // Complete menu example function onMCMOpen() { var modName = "MyCombatMod"; var settings = loadModSettings(modName); // Populate UI elements difficultySlider.value = settings.difficulty; enabledCheckbox.selected = settings.enabled; multiplierInput.text = settings.multiplier.toString(); presetDropdown.selectedLabel = settings.preset; } function onMCMClose() { var modName = "MyCombatMod"; // Gather values from UI var settings = { difficulty: difficultySlider.value, enabled: enabledCheckbox.selected, multiplier: parseFloat(multiplierInput.text), preset: presetDropdown.selectedLabel }; // Save all settings saveModSettings(modName, settings); } ``` -------------------------------- ### MCM Version History Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt A log of MCM releases, including version numbers, codes, and notable changes. ```APIDOC ## MCM Version History A log of MCM releases, including version numbers, codes, and notable changes. ### v1.40 (Version Code 9) - Public release v1.40 - Support for game version v1.10.984 ### v1.34 (Version Code 6) - Public release v1.34 - Added GetListFromForm Scaleform function ### v1.24 (Version Code 4) - Public release v1.24 - Support for game version v1.10.75 - Fixed: Issue with deactivated mods continuing to satisfy a MCM menu's plugin requirements. ### v1.23 (Version Code 4) - Public release v1.23 - Support for game version v1.10.64 ### v1.22 (Version Code 4) - Public release v1.22 - Support for game version v1.10.50 ### v1.21 (Version Code 4) - Public release v1.21 - Support for game version v1.10.40 - Started work on game version independence. ### v1.20 (Version Code 4) - Public release v1.20 - No backend changes ### v1.12 (Version Code 3) - Public release v1.12 - Support for game version v1.10.26 ### v1.10 (Version Code 2) - Public release v1.10 - Automatic fallback to EN strings if translations are not present. ### v1.06 - Support for ESL plugins - Updated runtime mismatch error message to be more user-friendly. - Abstracted Get/SetPropertyValue out of ScaleformMCM and into MCMUtils. ### v1.05 - Updated runtime mismatch error message to correct swapped version numbers. - Added mouse and gamepad button conflict detection - New valueSource type: PropertyValue - Added MCM Scaleform functions: GetPropertyValue, SetPropertyValue ### v1.0 (Version Code 1) - Initial public release. - Better runtime version checking. - Enabled mouse hotkeys. ### v0.67 - Updated MCM Scaleform functions: CallQuestFunction can now also call functions on non-Quest forms. ### v0.66 - Updated MCM Scaleform callback: ProcessUserEvent ### v0.65 - Automatically create MCM folder if not present. - Automatically create MCM\Settings folder if not present. - Added MCM Scaleform functions: OnMCMOpen - Removed MCM Scaleform functions: StartKeyCapture/StopKeyCapture ### v0.64 - ModSetting defaults are now defined in MCM\Config\ModName\settings.ini - Keybinds are now serialized to disk when the MCM menu is closed. - Removed Scaleform function invocation logging. - Added MCM Scaleform functions: OnMCMClose - Removed MCM Scaleform functions: SetKeybindEx - Updated MCM Scaleform functions: GetConfigList - Added Papyrus functions: RefreshMenu ### v0.63 - Support for game version 1.10.20 ### v0.62 - Enabled RunConsoleCommand keybind action type. - Added MCM Scaleform functions: DisableMenuInput ### v0.61 - Added translation support (Interface\Translations\mcm_xx.txt) ### v0.6 - Added keybind action types: CallGlobalFunction, RunConsoleCommand, SendEvent - Support for Control and Alt modifiers for keybinds. - Added MCM Scaleform functions: GetConfigList, GetMCMVersionCode, GetMCMVersionString - Updated MCM Scaleform functions: SetKeybind - Active keybind registrations are now stored in MCM\Settings\Keybinds.json - Keybind definitions are now stored in MCM\Config\\keybinds.json - Support for function parameters for keybind actions. ### v0.5 - Fixed issue with StopKeyCapture causing CTD if called within ProcessKeyEvent. - Added keybind/hotkey support - Added MCM Scaleform functions: IsPluginInstalled, GetAllKeybinds, GetKeybind, SetKeybind, ClearKeybind, RemapKeybind ### v0.4 - Fixed a buffer overflow issue that could occur with too many INI settings in a single file. - Added MCM Scaleform functions: StartKeyCapture, StopKeyCapture - Added MCM Scaleform callback: ProcessKeyEvent ### v0.3 - Added ModSetting support - Added MCM Scaleform functions: Get/SetModSettingInt, Get/SetModSettingBool, Get/SetModSettingFloat, Get/SetModSettingString - Added Papyrus functions: Get/SetModSettingInt, Get/SetModSettingBool, Get/SetModSettingFloat, Get/SetModSettingString ### v0.2 - Added MCM Scaleform functions: GetGlobalValue, SetGlobalValue, CallQuestFunction, CallGlobalFunction ### v0.1 - MCM menu injection ``` -------------------------------- ### Manage Integer Settings with F4MCM (Papyrus) Source: https://context7.com/reg2k/f4mcm/llms.txt Provides functions to read and write integer settings for mods using the F4MCM plugin. Settings are persisted in INI files, with defaults read from `Data\MCM\Config\ModName\settings.ini` and user changes saved to `Data\MCM\Settings\ModName.ini`. This allows modders to control game parameters like difficulty or combat multipliers. ```papyrus ; Read and write integer mod settings int Function GetDifficultySetting(string modName) global ; Returns integer value from ModName.ini ; Returns -1 if setting not found return MCM.GetModSettingInt(modName, "iDifficulty:Gameplay") EndFunction Function UpdateDifficulty(string modName, int newDifficulty) global ; Saves to Data\MCM\Settings\ModName.ini under [Gameplay] section MCM.SetModSettingInt(modName, "iDifficulty:Gameplay", newDifficulty) ; Setting is immediately written to disk EndFunction ; Complete example for a combat mod Event OnPlayerLoadGame() string myMod = "MyCombatMod" int damageMultiplier = MCM.GetModSettingInt(myMod, "iDamageMultiplier:Combat") int healthBonus = MCM.GetModSettingInt(myMod, "iHealthBonus:Combat") if damageMultiplier > 0 ; Apply damage multiplier to game systems Game.SetGameSettingFloat("fDamagePlayerDamageMult", damageMultiplier as float / 100.0) endif ; Update settings based on player actions if healthBonus < 200 MCM.SetModSettingInt(myMod, "iHealthBonus:Combat", healthBonus + 10) endif EndEvent ``` -------------------------------- ### MCM Scaleform GetConfigList Function Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt The GetConfigList Scaleform function retrieves configuration data. It supports specifying a full path or a filename for the configuration file, defaulting to 'config.json' in the MCM settings directory. ```Scaleform GetConfigList(fullPath:Boolean=false, filename:String="config.json") ``` -------------------------------- ### MCM Scaleform Get/SetKeybindEx Function Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt The SetKeybindEx Scaleform function was available for setting keybinds, likely with extended options compared to SetKeybind. This function was later removed in version 0.64. ```Scaleform SetKeybindEx(keybindName:String, key:String, mod:String, action:String, ...args):Boolean ``` -------------------------------- ### Configure Mod Settings using INI Format Source: https://context7.com/reg2k/f4mcm/llms.txt INI files are used to define default settings for mods. They are structured with sections and key-value pairs. User-specific settings, saved via MCM, override these defaults and follow the same format. ```ini ; Data\MCM\Config\MyMod\settings.ini - Default settings [General] sModName=My Awesome Mod sVersion=1.0.0 bEnabled=1 [Gameplay] iDifficulty=5 fDamageMultiplier=1.5 bHardcoreMode=0 [UI] bShowNotifications=1 iNotificationDuration=3 sNotificationPosition=TopRight [Combat] fWeaponDamage=100.0 iArmorRating=50 bRealisticHeadshots=1 [Advanced] sCustomScript=MyScript.pex iDebugLevel=0 ; User settings saved to Data\MCM\Settings\MyMod.ini ; Automatically created when user changes settings via MCM ; Overrides defaults from Config directory ; Format is identical - [Section] followed by key=value pairs ``` -------------------------------- ### Papyrus Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This section details the Papyrus functions available in the MCM API for interacting with mod settings. ```APIDOC ## Papyrus Functions This section details the Papyrus functions available in the MCM API for interacting with mod settings. ### Get/SetModSettingInt - **Description**: Gets or sets an integer mod setting. - **Method**: Papyrus - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (int) - Optional. The new integer value to set. - **Returns**: `int` - The current or new value of the mod setting. ### Get/SetModSettingBool - **Description**: Gets or sets a boolean mod setting. - **Method**: Papyrus - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (Boolean) - Optional. The new boolean value to set. - **Returns**: `Boolean` - The current or new value of the mod setting. ### Get/SetModSettingFloat - **Description**: Gets or sets a float mod setting. - **Method**: Papyrus - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (Float) - Optional. The new float value to set. - **Returns**: `Float` - The current or new value of the mod setting. ### Get/SetModSettingString - **Description**: Gets or sets a string mod setting. - **Method**: Papyrus - **Parameters**: - `settingName` (String) - The name of the mod setting. - `newValue` (String) - Optional. The new string value to set. - **Returns**: `String` - The current or new value of the mod setting. ### RefreshMenu - **Description**: Refreshes the MCM menu. - **Method**: Papyrus ``` -------------------------------- ### MCM Scaleform ProcessKeyEvent Callback Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt The ProcessKeyEvent Scaleform callback is triggered when a key event occurs while key capture is active. It provides the key code and a boolean indicating whether the key was pressed down or released. ```Scaleform ProcessKeyEvent(keyCode:int, isDown:Boolean) ``` -------------------------------- ### MCM Scaleform ProcessUserEvent Callback Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt The ProcessUserEvent Scaleform callback is updated to handle user input events. It receives the control name, a boolean indicating if the control is down, and the device type used for the input. ```Scaleform ProcessUserEvent(controlName:String, isDown:Boolean, deviceType:int) ``` -------------------------------- ### MCM Scaleform OnMCMOpen and OnMCMClose Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt These MCM Scaleform functions are designed to be called when the MCM menu is opened and closed, respectively. They allow for custom logic or state management at the beginning and end of an MCM menu session. ```Scaleform OnMCMOpen OnMCMClose ``` -------------------------------- ### Manage Boolean Settings with F4MCM (Papyrus) Source: https://context7.com/reg2k/f4mcm/llms.txt Enables reading and writing boolean (true/false) settings for mods via F4MCM. These settings control feature toggles, UI elements, or other binary options within a mod. The functions `IsFeatureEnabled` and `ToggleFeature` abstract the underlying INI file operations. ```papyrus ; Read and write boolean mod settings bool Function IsFeatureEnabled(string modName, string featureName) global ; Returns true if setting value is non-zero return MCM.GetModSettingBool(modName, "b" + featureName + ":Features") EndFunction Function ToggleFeature(string modName, string featureName, bool enabled) global MCM.SetModSettingBool(modName, "b" + featureName + ":Features", enabled) EndFunction ; Complete example for feature toggles Scriptname MyModConfigScript extends Quest string Property ModName = "MyAwesomeMod" AutoReadOnly Event OnInit() ; Initialize features based on MCM settings ApplySettings() EndEvent Function ApplySettings() bool useCustomAI = MCM.GetModSettingBool(ModName, "bUseCustomAI:Features") bool enableLoot = MCM.GetModSettingBool(ModName, "bEnableLoot:Features") bool showNotifications = MCM.GetModSettingBool(ModName, "bShowNotifications:UI") if useCustomAI ; Enable custom AI logic Debug.Trace("Custom AI enabled") endif if !enableLoot ; Disable loot drops Debug.Trace("Loot disabled") endif EndFunction Function OnMenuClose() ; Called when MCM menu closes - reapply settings ApplySettings() EndFunction ``` -------------------------------- ### MCM Scaleform CallQuestFunction Update Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This update to the CallQuestFunction Scaleform function expands its capability beyond just Quest forms. It can now also invoke functions on non-Quest forms, providing more flexibility in interacting with various game objects through Scaleform. ```Scaleform CallQuestFunction(formIdentifier:String, functionName:String, ...args) ``` -------------------------------- ### MCM Scaleform Global Value and Quest Function Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This set of MCM Scaleform functions allows for direct interaction with global game values and functions within quests. GetGlobalValue and SetGlobalValue manage global variables, while CallQuestFunction and CallGlobalFunction invoke specific functions. ```Scaleform GetGlobalValue(globalName:String):* SetGlobalValue(globalName:String, value:*):void CallQuestFunction(questName:String, functionName:String, ...args) CallGlobalFunction(functionName:String, ...args) ``` -------------------------------- ### MCM Scaleform GetListFromForm Function Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt The GetListFromForm Scaleform function is added to retrieve a list of items or data associated with a form. This function was introduced in version 1.34 and provides a way to query structured data from game forms via Scaleform. ```Scaleform GetListFromForm(formIdentifier:String):Array ``` -------------------------------- ### Papyrus RefreshMenu Function Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt This Papyrus function is available to trigger a refresh of the MCM menu. This can be useful for updating the menu's state or displayed information after certain game events or modifications. ```Papyrus RefreshMenu() ``` -------------------------------- ### MCM Scaleform GetPropertyValue and SetPropertyValue Functions Source: https://github.com/reg2k/f4mcm/blob/master/changelog.txt These MCM Scaleform functions allow retrieval and modification of property values for a given form identifier. They are part of the core MCM functionality for interacting with game forms. The GetPropertyValue function returns the current value of a property, while SetPropertyValue attempts to set a new value and returns a boolean indicating success. ```Scaleform GetPropertyValue(formIdentifier:String, propertyName:String):* SetPropertyValue(formIdentifier:String, propertyName:String, newValue:*):Boolean ```