Mod Settings API

Documentation on how to implement custom setting into your Puck mod using the Mod Settings API

Steam WorkshopView Docs

Getting Started

Firstly, you will need to add the API's DLL file as a dependency in your csproj.

To download the DLL, follow these steps:

  1. Visit the Steam Workshop page to download the necessary DLL file.

  2. Once downloaded, find the DLL file in your workshop files. /content/2994020/3496891216

  3. Open your project's dependency manager.

  4. Add a reference to the DLL file, specifying its path to ensure your project recognizes it as a dependency.

Registering with the API

To implement custom settings in your mod, utilize the ICustomSettings interface. This involves creating a class that implements ICustomSettings, which allows you to define how settings are displayed and managed.

Here's a simple example of an implementation:

public class Plugin : IPuckMod, ICustomSettings
{
    public SettingsPage SettingsPage;
    public bool OnEnable()
    {
        // Register this mod with the custom settings manager
        CustomSettingsManager.Register(this);
        return true;
    }

    //Mod name displayed in UI
    public string GetName()
    {
        return "My New Mod";
    }

    // Code to display your settings page
    public void ShowSettings()
    {
        SettingsPage.Show();
    }

    public bool OnDisable() 
    { 
        return true; 
    }
}

Now that your mod is registered it should appear within the game UI.

Creating a Settings Page

Creating settings pages is a streamlined process when using the API, however it should be noted that creating your own pages is 100% supported.

To create a page using the included SettingsBuilder class, do the following:

Initialization

Start by creating a new SettingsPage object. This will serve as the template for your custom settings. Set a title and footer to personalize your page.

// Creates a new settings page
SettingsPage = new SettingsPage("My Settings Page", "Example Footer");

Input

We will incorporate a toggle into the settings page for demonstration purposes.

// Adds a toggle option to the settings page
SettingsPage.AddOptionToggle("Here is a toggle: ", MyTestMethod);
// Called when the toggle is clicked
void MyTestMethod(bool state){
    Debug.Log($"Toggle state : {state}")
}

Compile and Test

Compile your mod and test it in game. It should appear in Mod Options on the menu screen. If you are encountering issues I recommend Toaster's Console to help in finding where errors may be occurring.

Last updated