Home > Tutorials > How to Make Your Mod Configurable with DragonAge.ini

How to Make Your Mod Configurable with DragonAge.ini

Recently I found myself in a small dilemma. My mod, No Follower Autolevel, was starting to go in several directions at once. Some people wanted it to act one way, others wanted it to act another. Still, others a third way. I didn’t like the thought of having to maintain three versions of the mod, so I started to look for a way to make everyone happy in one mod.

What I stumbled upon was a way to actually read in configuration settings from the DragonAge.ini file which stores the users settings. Let’s take a look.

DragonAge.ini

By default, this file is located in

My Documents\Bioware\Dragon Age\Settings

You will see a few ini files in there. The one we can interact with is DragonAge.ini. You can open that up in notepad by default just by double clicking it. It has many game options. One I found useful as a modder is DisableIntroMovies πŸ™‚ My game starts a lot faster now.

Structure of the INI File

DragonAge.ini follows the standard INI file format. There are essentially two types of lines. Sections and Parameters.

[VideoOptions]
ResolutionWidth=1680
ResolutionHeight=1050
FullScreen=1
UseVSync=1

Sections help break the file up, and parameters define actual values. In the snippet above, the section is “[VideoOptions]” and the others are parameters defining actual values. Note that there is no space around the equals sign, and no blank lines. Adding a new section or parameter is as easy as just opening this file into notepad and typing in the change.

Want to see something neat? Add this, and then start a NEW game:

[DebugOptions]
SkipCharGen=1

Using the INI File in a Mod

The scripting system has access to this INI file through the use of the following function:

string ReadIniEntry(string sSection, string sParameter)

sSection   = The section of the INI file to read.  Do not include the brackets.
sParameter =  The parameter to read.

Returns: The value of the specified parameter as a string

Once you have that value, you can use it in any logic you need. For example:

string sOption = ReadIniEntry("NoFollowerAutolevelOptions", "FollowerSpecs");
if (sOption == "1")
{
    // Grant one specialization point
    SetCreatureProperty(OBJECT_SELF, 38, 1.0f);
}
else if (sOption == "2")
{
...
Advertisements
Categories: Tutorials
  1. Pheelon
    November 20, 2009 at 11:48 am

    thx a lot – this will tunr out to be most usefull πŸ™‚

  2. November 20, 2009 at 11:57 am

    Thanks!! How did you ever figure this out?

    Great, great work! Keep it up, you’re style and ability is much appreciated by many of us!

    • John Vanderbeck
      November 20, 2009 at 12:02 pm

      Luck more than anything πŸ™‚ I usually spend an hour or two trolling the script code each day and when I started thinking about my problem, I suddenly recalled that I had seen something about reading an ini file in some script πŸ™‚

  3. Jean
    November 20, 2009 at 1:04 pm

    Great work. Though I am not sure which would be easier for the average gamer, having to decide between two or tree versions of your mod and then simply extracting them to the override directory, or manually editing an ini file with the possibility of spelling errors and what not.

    Still, great find. Would there be any way to include/exclude certain m2da files via this method? As in, at the start of the game load a script that loads or skips certain m2da files?

    • John Vanderbeck
      November 20, 2009 at 1:07 pm

      Couple of things you can, and should, do to deal with user error. First off, always have a “default” behavior. Even if the user fails to enter the INI data, or messes it up, the mod should work at a default level. Second, what I did in my mod was actually include the exact text to copy/paste

      As for m2das no it doesn’t really work that way.

  4. Innodil
    November 20, 2009 at 3:51 pm

    Great tip, that finally helps me with setting a debug flag to output debug messages for my module in a DECENT way (now I set a const and need to recompile all scripts when I change it due to the static include system 😦 )

    • John Vanderbeck
      November 20, 2009 at 3:55 pm

      Have you gotten any debug functions other than the floaty message to work?

  5. November 22, 2009 at 2:26 am

    Be careful when using this construct in frequently called scripts, it can be a bit slow under certain circumstances.

    • John Vanderbeck
      November 22, 2009 at 10:34 am

      Hey Georg I was actually SHOCKED last night at how efficient this call actually is. I had a script running in HEARTBEAT2 on the player and using this to read in 4 values every heartbeat without any significant slowdown! Obviously in the end I cached the values, but I was surprised πŸ™‚

  6. December 18, 2009 at 1:07 pm

    While implementing this in my mod I was wondering; when checking if a certain feature should be enabled, using DoEnable=0 and DoEnable=1, what if the user doesn’t add the required lines to the ini, does that mean the variable will always return 0, in other words always disabling that feature when checking if(DoEnable == 0 || 1)?

    I guess it would be better to check for DoEnable=Yes and =No, as then you can actually check if DoEnable == “yes”|| “no” and not triggering that if statement if no value is returned, or am I incorrect in assuming ReadIniEntry returns 0 on failure?

  7. John Vanderbeck
    December 18, 2009 at 1:20 pm

    Since the return is a string, it returns “” if the value is not in the INI file.

  8. December 18, 2009 at 1:48 pm

    Oh right, it’s a string. Totally forgot about that because I StringToInt all returns. Thanks for that.

  9. Tim
    December 22, 2009 at 5:49 am

    Sorry, but I donΒ΄t know whom to ask:

    I build a “Summon little Help”-Spell for my mage. It should be a kind of flying-eye.
    Therefore: How to increase the walking-speed of the creature “little_helper.utc”??

    I think the constant could be set by something like:
    “const float little_helper_ANIM_WALKSPEED = 0.5f;”

    Bur what command exactly?

  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: