⚙️Adding Configurations
Adding configurations to your plugin is pretty straightforward!
Configuration Class
Any class that can be serialized is a class that can be used for configuration.
For example:
public class MyModuleConfigurationClass
{
public int MyConfigurableInt { get; set; } = 10; // 10 is the default value
}Fields aren't serialized! You must use properties.
Getting a config
To get a config you just have to call the GetConfig<T>(string) method inside your module class:
public class MyFirstModule : CursedModule
{
// public override string ModuleNam....
public MyModuleConfigurationClass Configuration;
public override void OnLoaded()
{
Configuration = GetConfig<MyModuleConfigurationClass>("File Name");
base.OnLoaded();
}
}"File Name" will be the name of the configuration file inside the module folder!
Saving a config
To save a config you just have to call the SaveConfig<T>(T, string) method inside your module class:
In this case the configuration file would be overrided with the property MyConfigurableInt changed to 5.
Last updated
Was this helpful?