Introduction to Pluggy INI Files

Revision as of 18:13, 1 March 2008 by imported>Speedo (→‎Keys)

The latest version of Pluggy supports the use of INI config files. This article gives a brief overview of INI files and their usage.

What is an INI?

The INI file is the most common type of file for storing configuration settings in the MS Windows environment. The basic elements of the INI file are as follows.

Sections

A section is denoted by a name in square brackets ([]). Sections are used primarily for the organization of data within the file, so that it is easier to find information when viewing an INI file in a text editor. For example, if I wanted to create an INI that stored detailed information about the player's character, I might want to use some of these sections to keep the file organized:

[General]
[Attributes]
[Skills]
[Spells]
[Equipped Items]

Keys

The key is where the actual information is stored within the INI file. With the functions available in Pluggy, we can read and store 4 types of data:

Each key has a name, with an equals sign (=) separating the key's name from the key's value. We can now expand our INI file about the player with actual data:

[General]
Name=Sir Rupert the Lame
Level=9
Gold=1489

[Attributes]
Health=248.3

 ...

[Spells]
ActiveSpell=000A97DF

[Equipped Items]
Weapon=00000C0D

Comments

Like in Oblivion Scripting, comments are denoted by a semicolon (;) at the start of the commented text. Expanding our INI file again with comments, we now have:

[General]
;Name is a string
Name=Sir Rupert the Lame
;Lvl & gold are ints
Level=9
Gold=1489

[Attributes]
;Health is a float
Health=248.3

 ...

[Spells]
;StandardFireDamageTarget1Novice ("Fireball")
ActiveSpell=000A97DF

[Equipped Items]
;WeapIronShortSword ("Iron Shortsword")
Weapon=00000C0D

When should I use an INI?

Generally, any time that you want to use a list of settings that can be modified outside of the game. INI files could also be used as a means to store data in an organized manner, allowing players to share information (such as data about their character, in the above examples) or settings with friends.

INI vs. RunBatchScript

Many people are already using files to load settings via the OBSE function RunBatchScript - why then would you want to use INI files? Well, they have several advantages.

  • Data is more organized, so it's easier for players to understand what they're looking at when editing the file.
  • The "KeyName=Value" syntax of INIs simple and more direct than the "set SomeVariable to Value" scripting commands needed by RunBatchScript
  • The IniRead___ functions require you to give them a default value which is used if a key is invalid or the player has accidentally damaged the INI file.
    • Because of the default values, less code is needed to check the loaded data for errors; simply go ahead and use the default values.
  • The IniWrite___ functions can be used to update any values that may have changed via an ingame setup menu or etc. There's simply no way to do this with RunBatchScript.

Relevant Functions

See each function's page for more information about its syntax and usage.

Loading Data

Saving to File

Other INI functions