Skip to content

Options

Difficult_Bit2901 edited this page Mar 9, 2023 · 1 revision

Introduction

In Difficult Engine it is possible to add custom options to the options menu. These will appear in the Engine and Custom section and only affect the mod folder they belong to.

Options json

These function similar to custom achievements. First navigate to mods/YOUR MOD/data/ and add a file called options.json. The structure of the file is like this:

{
    "options": [
        {
            "name": "Option 1",
            "description": "Description for Option 1",
            "variable": "option_1",
            "type": "bool",
            "value": true,
            "options": []
        },
        {
            "name": "Option 2",
            "description": "Description for Option 2",
            "variable": "option_2",
            "type": "string",
            "value": "Default",
            "options": ["Default","Secondary"]
        }
}

The name is the text displayed in the options menu.
The description is also displayed and should contain what the option does.
The variable is what differentiates this option from others.
The type changes how the option behaves.
Percent is a range between 0 and 1. Bool is either true or false. String can take all values inside options.
Value is the default value the option has. If the type is string it should also be contained within options.
Options is a list of possible values a string type option can have.

Setting / Getting the option's value

To make the options actually do something you need to create a lua file. If the option should always affect something add the script to mods/YOUR MOD/scripts/ otherwise add it to wherever you want something to be changed through the option.
To get a custom option's value use getCustomSetting(variable). To set the value use setCustomSetting(variable, value).

Warning!

Globally loading mods that contain options might break when playing songs from the base game or other mods.
The option types int and float should not be used.

Clone this wiki locally