Modding:ModConfig

From Vintage Story Wiki
Jump to navigation Jump to search

The game provides the following convenience methods for saving and loading mod configuration data by serializing the data into JSON format.

StoreModConfig() will save your mod's configuration file to the Vintage Story app data folder within a "ModConfig" subdirectory. LoadModConfig will load the same file from that directory back into the data structure class you've defined. You can use standard JSON.NET features, such as using the [JsonIgnore] attribute for certain fields or properties that you do not wish to be serialized to file.

        /// <summary>
        /// Milo kept asking for a standardized way to load and store mod configuration data, so here you go :P
        /// For T just make a class with all fields public - this is your configuration class. Be sure to set useful default values for your settings
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="jsonSerializeableData"></param>
        /// <param name="filename"></param>
        void StoreModConfig<T>(T jsonSerializeableData, string filename);

        /// <summary>
        /// Milo kept asking for a standardized way to load and store mod configuration data, so here you go :P
        /// Recommendation: Surround this call with a try/catch in case the user made a typo while changing the configuration
        /// Returns null if the file does not exist
        /// 
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="filename"></param>
        /// <returns></returns>
        T LoadModConfig<T>(string filename);


Main Page: Modding
Green Items require C# coding
Basics

Getting Started | Mod Types | Simple Examples

Asset System | Textures | Items | Recipes | Blocks | Model Creator | Animation Basics | VTML & Icons | Mod Packaging & Release | Modinfo | Debugging

Advanced

JSON Patching | Advanced JSON Items | The Remapper | Server-Client Considerations

Setting Up Your Development Environment (General - Windows - Linux)

Advanced Blocks | Advanced Items | Item-Block Interactions | Block Behavior | Block Entities | Particle Effects | World Access | Inventory Handling | Chat Commands | GUIs | Server-Client Networking | Monkey patching (Harmony)

Data Management

Savegame Data Storage | ModConfig File | Chunk Data Storage | Tree Attribute

Worldgen

WorldGen Concepts | Terrain | Ores | Trees | WorldGen API

Rendering

Shaders and Renderers

Property Overview

Item | Entity | Block | Block Behaviors | Block Classes | Block Entities | Block Entity Behaviors

Workflows & Infrastructure

Modding Efficiency Tips | Mod Extensibility | Load Order

Additional Resources

List of server commands | List of client commands | Client startup parameters | Creative Starter Guide | ServerBlockTicking | Bot System | WorldEdit | Cinematic Camera

Example Mods | API Docs | GitHub Repository