> For the complete documentation index, see [llms.txt](https://wood-comet.gitbook.io/puck-settings-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://wood-comet.gitbook.io/puck-settings-api/mod-settings-api.md).

# Mod Settings API

<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=3496891216" class="button secondary">Steam Workshop</a> <a href="/pages/hpClfE8MENfvGEQcI5dG" class="button secondary">View Docs</a>

## 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](https://steamcommunity.com/sharedfiles/filedetails/?id=3496891216) to download the necessary DLL file.
2. Once downloaded, find the DLL file in your workshop files. `/content/2994020/3496891216`&#x20;
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:

```csharp
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.

```csharp
// 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.&#x20;

```csharp
// Adds a toggle option to the settings page
SettingsPage.AddOptionToggle("Here is a toggle: ", MyTestMethod);
```

```csharp
// 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](https://steamcommunity.com/sharedfiles/filedetails/?id=3494534057) to help in finding where errors may be occurring. &#x20;
