Configuring Mods

From The Stardew Modding Wiki
Jump to navigation Jump to search

Many mods are configurable. This means they have different options you can change, whether it's what color a chicken should be or making the mod compatible with Stardew Valley Expanded.

How do I know if a mod has configuration options?[edit | edit source | hide | hide all]

  1. The easiest way is to just look at the description on the page you downloaded it from. Mod authors will usually specify the options available. Mushroom Propagator is a great example of a mod with many options and clearly explains what they do.
  2. Alternately, you can look at the Json file(s) in the mod's folder. Configuration options are set using the "ConfigSchema" property. Looking at the json file will show you all the choices and may also include a description of what they do.

How can I change configuration options?[edit | edit source | hide]

  1. Use a mod like Generic Mod Config Menu, which will display all the options for all configurable mods you have and allows you to easily change them.
  2. Directly edit the mod's config.json file. This file is automatically generated in the mod's folder after you have loaded Stardew Valley at least once via SMAPI. Make sure you use the exact same capitalization, spelling, and spacing as the mod tells you to do or else you may cause errors.

How do I add configuration to my own mod?[edit | edit source | hide]

  1. Add a config schema to content.json. Here is an example:
      "ConfigSchema": { 
    		"Option 1": {"AllowValues": "True, False",
    		"Description": "Turns option 1 off (false) or on (true).",
    		"Default": "True"},
    		"Option 2": {"AllowValues": "Red, Blue, Green, Yellow",
    		"Description": "Set the color of something in the mod.",
    		"Default": "Red"},
    		"Option 3": {"AllowValues": "Red, Blue, Green, Yellow, False",
    		"Description": "Set the color of something else in the mod, or turn off coloring the item entirely with false.",
    		"Default": "False"},
  2. Later in your code, you can reference the configuration option. There are two common methods.
    1. One is to use the option with a "when" statement, like this:
      "When": {
      			"Option 1": "True",
      			"Option 2": "Red",
    2. The other is to use the option to easily change the file path used, such as for which portrait or sprites to grab. You can see this kind of code in Elle's New Barn Animals or Diverse Stardew Valley.
    3. All available options can be found in Pathoschild github.