Jump to content

Where to find a good example on making a config?


Recommended Posts

Hi, I have been trying to figure out how to use the config. I have taken a look at various mods, in particular Global Player Icons. So far, this is what I know : (correct me if anything's wrong)

 

The set up in my modinfo should look like this :

configuration_options ={    {        name = "language",        label = "Set Language",        options =        {            {description = "English", data = 1},            {description = "Français", data = 0},        },        default = 1,    },}

And in my modmain, I need to add this to be able to refer to my configuration :

local LANGUAGECONFIG=GetModConfigData("language")

But I don't know how to link my "LANGUAGECONFIG" to anything. The purpose of this particular config is to allow my playable character mod to be chosen to speak English or French. Maris has shown me how to detect if the user has the French patch, thanks again by the way.

 

Yet I still don't know how to go on from this point. How do I tell my character which speech it can use? I guess I need to use the "LANGUAGECONFIG" thing, but I just don't really know how... Can anyone give me a clear example? Do I need to switch between two (English/French) speech files? Thanks in advance, guys :-).

Edited by Thibooms
Link to comment
Share on other sites

That's all mod configurations do: allow user input. What you do with it, nobody knows.

 

As for what to do, you literally said it. Here's some pseudo-code to give you a precise idea:

 

if Language_Config == 1 then

  STRINGS.CHARACTERS.WUBWUB = require("speech_wubwub_fr")

else

  STRINGS.CHARACTERS.WUBWUB = require("speech_wubwub_en")

end

Link to comment
Share on other sites

That's all mod configurations do: allow user input. What you do with it, nobody knows.

I didn't ask what they did, I asked how to use them x).

 

What you do with it, nobody knows.

Ouch :(

 

if Language_Config == 1 then   STRINGS.CHARACTERS.WUBWUB = require("speech_wubwub_fr") else   STRINGS.CHARACTERS.WUBWUB = require("speech_wubwub_en") end

That's more like it! And excuuuse me for being so bad at this :p

The problem I was having seems to be a lack of understang the way to assign data. And translated to English, that means that I always crashed when trying to make the first if, because I didn't know you had to use "==".

 

Thank you!

Link to comment
Share on other sites

To be sure it's clear:

 

 in the config thingy,

"description" is what is displayed to the user when accessing the config screen

"data" is the actual data recovered in the modmain when doing GetModConfigData("my_config_param")

 

In your case, data are integer, but it could be whatever (bool, float, string, ...). So when using them you have to be consistent with the type of the data you used in the modconfig.lua.

 

PS: you can add a "hover = "fancy description here"" after the data, separated with a coma, to have something displayed when the user put his/her mouse on the config parameter.

Edited by ZupaleX
Link to comment
Share on other sites

To be sure it's clear:

Yeah, don't worry about it. Got it fully working more than half an hour ago ;) 

 

PS: you can add a "hover = "fancy description here"" after the data, separated with a coma, to have something displayed when the user put his/her mouse on the config parameter.

I know, thank you for helping, but I've actually seen that before too :p. I just felt like it was a bit useless in this case :)

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