Results 1 to 5 of 5

Thread: Is there a preferred way to make an SDX mod configurable?

  1. #1
    Refugee Ghost314's Avatar
    Join Date
    Mar 2018
    Location
    Ontario, Canada
    Posts
    18
    Rep Power
    0

    Question Is there a preferred way to make an SDX mod configurable?

    I'm about to release my first mod for 7D2D, which is an SDX mod that repositions zombie corpses just before they fall, in order to prevent them from being immediately destroyed from spawning in a bad location.

    I made a standard app.config and .settings file to store and load some settings for things like, how far the algorithm should search for a proper spawn point. Ideally, I want the user to be able to change these settings by altering the files and restarting 7D2D without having to re-build the entire mod.

    After building my mod, I can't seem to find the config or settings files anywhere in the game directory, which makes them kind of hard to edit . I'm wondering if any one knows what the SDX build tool is doing with those files, or if there is some other standard way for making configurable mods.

  2. #2
    Guppycurian Forum Whore Guppycur's Avatar
    Join Date
    Apr 2014
    Location
    Enemy for life
    Posts
    19,241
    Rep Power
    1
    I think the preferred method is to make a special class, so that in the xml you can add new lines to configure the new options.

  3. #3
    Refugee Ghost314's Avatar
    Join Date
    Mar 2018
    Location
    Ontario, Canada
    Posts
    18
    Rep Power
    0
    Quote Originally Posted by Guppycur View Post
    I think the preferred method is to make a special class, so that in the xml you can add new lines to configure the new options.
    So for example, I might define a new type of block that points to my settings class, and have my config options as custom properties on that new block type?

  4. #4
    Colony Founder sphereii's Avatar
    Join Date
    Dec 2015
    Posts
    3,092
    Rep Power
    1
    Quote Originally Posted by Ghost314 View Post
    So for example, I might define a new type of block that points to my settings class, and have my config options as custom properties on that new block type?
    Yes, that's the easiest and most streamline approach. I'm looking at different configuration options that would give us more flexibility, but it's still early in that process.

  5. #5
    Colony Founder StompyNZ's Avatar
    Join Date
    Apr 2015
    Posts
    3,858
    Rep Power
    1
    if its a block or entity then adding properties is easy. If you need app wide settings then you might need to make a config xml or json file and read it in yourself

    For code to run at the start of the server try something like this:

    Code:
    class ModConfig : ModScript
    {
      private static Dictionary<string,string> params;
    
      public override void OnGameStarted()
      {
        //load the xml file and parse into the config dictionary here
        //then access the values via the static ModConfig.params.ContainsKey("item1") /  ModConfig.params["item1"] etc.
      }
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •