Jump to content

Workaround modinfo config saving for modders (sample)


Recommended Posts

I just thought I would share this sample mod configuration, showing blank lines and option-less labels in your mod config window.

 

With this current bug that doesn't allow the right side of your config window to save its options, this is a workaround to have your whole mod config save, as well as a way to make your config generally look sexier, as you can have it all down the left side, all down the right side (though you don't want that until next update!) or insert blank lines in both columns to produce separate "categories" of config within the window.

configuration_options ={    {        name = "yourmodsetting1",        label = "Config Option 1",        hover = "This will appear when you hover over Config Option 1! Rad!",        options =        {            {description = "1 Day", data = 1, hover = "Hovering Choice 1 of Config Option 1"},            {description = "2 Days", data = 2, hover = "Different hover for different chosen value"},        },        default = 1,    },    {        name = "blank",        label = " ",        hover = "This is kinda a secret hover, since nobody can see anything here to know to hover hehe",        options =        {            {description = " ", data = 0},        },        default = 0    },        {        name = "yourmodsetting2",        label = "Config Option 2",        options =        {            {description = "Is Nice", data = 0},            {description = "I Like!", data = 1},        },        default = 1    },        {        name = "blank",        label = " ",        options =        {            {description = " ", data = 0},        },        default = 0    },      {        name = "blank",        label = " ",        options =        {            {description = " ", data = 0},        },        default = 0    },      {        name = "blank",        label = " ",        options =        {            {description = " ", data = 0},        },        default = 0    },      {        name = "yourmodsetting3",        label = "Config Option 3",        options =        {            {description = "Because", data = 0},            {description = "Why Not?", data = 1},        },        default = 0,    },        {        name = "letsmakeitalabel",        label = "Can use these as labels :)",        options =        {            {description = "10 letters", data = 0},        },        default = 0,    },    }

If anyone wanted to make their mod configurable, they could just paste this directly into the modinfo and start work. Btw, you read things from the config within your modmain by just saying for example:

local somethingYN = GetModConfigData("yourmodsetting1")

and somethingYN now has that setting stored in it for use in code.

 

It would be really nice if we could get some more control over the config window to add labels and things in a less hack-ish way; are there any methods available I'm not yet aware of? :-)

 

*edit* code updated to show using tooltip on mouse hover over config items! Thanks Jjmarco!

Edited by outseeker
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...