Jump to content

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


Ghost314

Recommended Posts

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 :apthy: . 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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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:

 

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.
 }
}

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...