Table of Contents

Class TimbnConfig

Namespace
Timbn.GraveyardKeeperTwo.Core.Framework
Assembly
Timbn.GraveyardKeeperTwo.Core.dll

Helpers for a plugin's config file, for binding a slider or a hidden setting in one line and carrying a player's values over when a setting is renamed or moved.

public static class TimbnConfig
Inheritance
TimbnConfig
Inherited Members

Methods

BindHidden<T>(ConfigFile, string, string, T, string)

Binds a setting that stays out of the in game configuration manager, for a switch only a developer needs, such as turning on a plugin's debug log. It is still written to the config file and read like any other entry.

public static ConfigEntry<T> BindHidden<T>(this ConfigFile config, string section, string key, T defaultValue, string description)

Parameters

config ConfigFile

The plugin's config file.

section string

The section it goes under.

key string

The setting's name.

defaultValue T

The value until it is changed.

description string

What the setting does.

Returns

ConfigEntry<T>

The bound setting.

Type Parameters

T

Examples

WriteDebugLog = config.BindHidden("Debug", "WriteDebugLog", false, "Writes the debug log.");

BindRange<T>(ConfigFile, string, string, T, string, T, T)

Binds a setting that only accepts values between a lowest and a highest, which a config manager shows as a slider. It is the same as ConfigFile.Bind with an AcceptableValueRange, in one line.

public static ConfigEntry<T> BindRange<T>(this ConfigFile config, string section, string key, T defaultValue, string description, T min, T max) where T : IComparable

Parameters

config ConfigFile

The plugin's config file.

section string

The section it goes under.

key string

The setting's name.

defaultValue T

The value until the player changes it.

description string

What the setting does, shown to players.

min T

The lowest value allowed.

max T

The highest value allowed.

Returns

ConfigEntry<T>

The bound setting.

Type Parameters

T

Examples

TimeSpeed = config.BindRange("Meditation", "TimeSpeed", 7f, "How many times faster time runs while you meditate.", 1f, 50f);

CarryOver(ConfigFile, params (ConfigEntryBase Entry, string Section, string Key)[])

Moves the values of config entries a plugin has renamed or moved into their new entries, so players keep their settings across the change. Call it at the end of BindConfig, once every new entry is bound. An old entry is only used while it is still in the file, and it is removed from the file afterwards.

public static void CarryOver(ConfigFile config, params (ConfigEntryBase Entry, string Section, string Key)[] moves)

Parameters

config ConfigFile

The plugin's config file.

moves (ConfigEntryBase Entry, string Section, string Key)[]

Each new entry with the section and key it used to have.

Examples

TimbnConfig.CarryOver(
    config,
    (StuckCarriers, "Carriers", "ShowWhenStuck"),
    (UnstuckKey, "Unstuck", "Key"));