Skip to content
Doink Oink edited this page Sep 11, 2025 · 19 revisions

Initial Mod Setup

First create your script file that be used to create and manage your config files. In this example we will name it ExampleModConfig.gd

  • While you can do this in your Main.gd script I recommend creating a separate file to keep it clutter free
  • Make sure to place extends Node at the top of the script

ExampleModConfig.gd

extends Node

func _ready():
    pass

mod.txt Autoload

Add your config file to the mod.txt file under the [Autoload] section. This allows the script to be ran as the game first loads so your config file can be created/loaded before anything accesses it.

  • Make sure the path has the correct folder structure to point to the script just like your Main.gd script

mod.txt

[Autoload]
ExampleConfig="res://ModConfigruationMenu/ExampleModConfig.gd"

Config Constants

There are 2 constants that should be defined at the top of your config script to make config creation and registration easier. They are:

  • MOD_ID - A unique identifier for your mod's configuration registration. This does not need to be the same as your mod.txt id
  • FILE_PATH - This is the file path that your config file(s) will be stored. It is very important that your config files be saved at "user://MCM/{MOD_ID}/"

ExampleModConfig.gd

extends Node

const MOD_ID = "ExampleMod"
const FILE_PATH = "user://MCM/ExampleMod"

func _ready():
    pass

Creating The Config File

In the _ready() function

  1. Create variable and store the ConfigFile class in it: var _config = ConfigFile.new()
  2. Using FileAccess check to see if the config file exists: if !FileAccess.file_exists(FILE_PATH + "/config.ini"):
  3. Start setting your config values within your config variable: _config.set_value(...)
    • There is a very specific way these values need to be stored. We will go over this shortly
  4. After setting all your values we need to create the folder, using DirAccess, where the config files will be stored: `DirAccess.open("user://").make_dir(FILE_PATH)
  5. Save the config file to the system: `_config.save(FILE_PATH + "/config.ini")

ExampleModConfig.gd

extends Node

const MOD_ID = "ExampleMod"
const FILE_PATH = "user://MCM/ExampleMod"

func _ready():
	var _config = ConfigFile.new()
	if !FileAccess.file_exists(FILE_PATH + "/config.ini"):
		_config.set_value("String", "testString", {
			"name" = "Test String",
			"tooltip" = "A test string",
			"default" = "Hello World",
			"value" = "Hello World"
		})

		_config.set_value("Int", "testInt", {
			"name" = "Test Int",
			"tooltip" = "A test int",
			"default" = 5,
			"value" = 5,
			"minRange" = 0,
			"maxRange" = 20
		})

		_config.set_value("Float", "testFloat", {
			"name" = "Test Float",
			"tooltip" = "A test float",
			"default" = 10.3,
			"value" = 10.3,
			"minRange" = 0,
			"maxRange" = 50.5
		})
		
		_config.set_value("Bool", "testBool", {
			"name" = "Test Bool",
			"tooltip" = "A test bool",
			"default" = false,
			"value" = false
		})
		
		_config.set_value("Keycode", "testKeycode", {
			"name" = "Test Keycode",
			"tooltip" = "A test keycode",
			"default" = KEY_ALT,
			"value" = KEY_ALT
		})
		
		DirAccess.open("user://").make_dir(FILE_PATH)
		_config.save(FILE_PATH + "/config.ini")
	else:
		_config.load(FILE_PATH + "/config.ini")

The available config values

MCM Supports 5 different types of values

  • String
  • Integer
  • Float
  • Boolean
  • Keycodes

Array's of these types are not currently supported.

Instead of just storing a value in a normal variable we create a Dictionary type of structure for every value. This allows MCM to store control variables that is used in for the GUI aspect of the mod and allows the author to set default values to be reset if the player wishes.

The way MCM determines what type a value is is based on the Section that is passed in _config.set_value Take a look at the documentation to see what sections are

Because of this it is VERY important that the sections are written exactly as I have them in the or examples. If they aren't then they will not be displayed in the MCM menu.

  • String
  • Int
  • Float
  • Bool
  • Keycode

Let's go over the different types and how they should be set up.

String

mcm_string
_config.set_value("String", "testString", {
	"name" = "Test String",
	"tooltip" = "A test string",
	"default" = "Hello World",
	"value" = "Hello World"
})
  • Section - "String"
  • "name" - The friendly name of the value that will be displayed in the configuration menu.
  • "tooltip" - A short description of the value that will be displayed when hovering over the name in the configuration menu.
  • "default" - The default value that the player can revert back to in the configuration menu.
  • "value" - The current value that is set.

Int

mcm_int
_config.set_value("Int", "testInt", {
	"name" = "Test Int",
	"tooltip" = "A test int",
	"default" = 5,
	"value" = 5,
	"minRange" = 0,
	"maxRange" = 20
})
  • Section - "Int"
  • "name" - The friendly name of the value that will be displayed in the configuration menu.
  • "tooltip" - A short description of the value that will be displayed when hovering over the name in the configuration menu.
  • "default" - The default value that the player can revert back to in the configuration menu.
  • "value" - The current value that is set.
  • "minRange" - The minimum value the player is able to set the value to in the configuration menu.
  • "maxRange" - The maximum value the player is able to set the value to in the configuration menu.

Float

mcm_float
_config.set_value("Float", "testFloat", {
	"name" = "Test Float",
	"tooltip" = "A test float",
	"default" = 10.3,
	"value" = 10.3,
	"minRange" = 0,
	"maxRange" = 50.5
})

Bool

mcm_bool
_config.set_value("Bool", "testBool1", {
	"name" = "Test Bool 1",
	"tooltip" = "The first test bool",
	"default" = false,
	"value" = false
})
  • Section - "Bool"
  • "name" - The friendly name of the value that will be displayed in the configuration menu.
  • "tooltip" - A short description of the value that will be displayed when hovering over the name in the configuration menu.
  • "default" - The default value that the player can revert back to in the configuration menu.
  • "value" - The current value that is set.

Keycode

mcm_keycode
_config.set_value("Keycode", "testKeycode", {
	"name" = "Test Keycode",
	"tooltip" = "A test keycode",
	"default" = KEY_ALT,
	"value" = KEY_ALT
})
  • Section - "Keycode"
  • The Inputs action name will be the value name you set here for this example it would be testKeycode
  • "name" - The friendly name of the value that will be displayed in the configuration menu.
  • "tooltip" - A short description of the value that will be displayed when hovering over the name in the configuration menu.
  • "default" - The default value that the player can revert back to in the configuration menu.
  • "value" - The current value that is set.

An important note about Keycode's is that MCM will handle both registering it to the InputMap and updating the InputMap with any new values that the player sets. So as the author you will only ever need to set the value in the initial config file creation and just call Input.is_action_just_pressed() with whatever you named the value.

MCM_Helper File

MCM_Helper.gd is the main file you as a mod author will be using to register your config file with MCM. It holds a handful of helper functions that's used within the mod itself but only 1 that you need to worry about.

ReigsterConfiguration

The ReigsterConfiguration

Referencing the MCM_Helper resource

In order for you to register your mod with MCM you must load the MCM_Helpers.tres file. To do this place this line at the top of your script below the extends Node line: var McmHelpers = preload("res://ModConfigurationMenu/Scripts/Doink Oink/MCM_Helpers.tres")

ExampleModConfig.gd should now look like this

extends Node

var McmHelpers = preload("res://ModConfigurationMenu/Scripts/Doink Oink/MCM_Helpers.tres")

func _ready():
    pass

Registering your mod and associated config files with MCM

Handling configuration updates by the player

Clone this wiki locally