.

Lord Olleus said:
I have seen quite a few modds here that have a .ini file included, which allows users to change their settings for the mod. Does anyone here have a tutorial/guide on how to create your own .ini and implement it?

Personally Im not a fan of the ini files. Firaxis gave us GlobalDefinesAlt.xml to store tunables so I use that for configuration. There isn't much to it, just enter a new int in GlobalDefinesAlt.xml and reference it with gc.getDefineINT('<attribute name>') like:

Code:
    <Define>
        <DefineName>DISEASE_CHANCE</DefineName>
        <iDefineIntVal>50</iDefineIntVal>
    </Define>
    <Define>
        <DefineName>ORTHUS_TURN</DefineName>
        <iDefineIntVal>99</iDefineIntVal>
    </Define>
    <Define>
        <DefineName>SLAVERY_CHANCE</DefineName>
        <iDefineIntVal>25</iDefineIntVal>
    </Define>

Then in the code you reference it by:

Code:
		if CyGame().getSorenRandNum(100, "Bob") <= gc.getDefineINT('DISEASE_CHANCE'):

or:

Code:
		if iGameTurn == gc.getDefineINT('ORTHUS_TURN'):
 
Lord Olleus said:
I have seen quite a few modds here that have a .ini file included, which allows users to change their settings for the mod. Does anyone here have a tutorial/guide on how to create your own .ini and implement it?
An ini file is just a text file with sections (ie. [SectionName]) and Name=Value pairs. You can create one manually. The trick is using it in python. ;) Dr Elmer Jiggle created a utility that shows how it's done: http://forums.civfanatics.com/showthread.php?t=157141

Although, I would agree with Kael that the GlobalDefinesAlt.xml seems a simpler way to go.
 
The problem I have with the GlobalDefinesAlt.xml file is that you can only have one, so if you have 12 mod components that have a GlobalDefinesAlt.xml file the resulting one could be huge. By using INI files you can keep each INI file for each mod component. Or you can create one with individual sections.
 
Kael said:
Personally Im not a fan of the ini files. Firaxis gave us GlobalDefinesAlt.xml to store tunables so I use that for configuration.

The README for one of the early Hall of Fame mods (by Dianthus, I think) hinted that using GlobalDefinesAlt.xml causes problems in an environment like Game of the Month or Hall of Fame where cheating is not allowed. My impression is that the cheat prevention functionality is implemented with a checksum of all assets files. Therefore, if someone wants to change a setting, editing GlobalDefinesAlt.xml will change the checksum and trigger the cheat flag. That was my main reason for doing the .INI stuff in my alerts mod.

Some of the other advantages are, as The Lopez mentioned, that it's easier to keep options for different mods separated. Also, I think non-programmers are a little less likely to be intimidated by and/or mess up an INI file than an XML file. If they do mess it up, it's also probably less likely that an error in an INI file will totally screw up the whole game.

But, having said all that, you're right that GlobalDefinesAlt.xml is clearly the more officially sanctioned way of dealing with that sort of thing.

Oh yeah. The other problem I had with GlobalDefinesAlt.xml was that there was a weird timing problem with when it gets initialized. I forget the details, but it was something like that if you try to catch the onInit event to do some startup processing, the settings haven't been read yet. So you need to do some weird hacks to delay all your initialization until after onInit (which seems really stupid; what's the point of an init event where you can't initialize?).
 
Dr Elmer Jiggle said:
Some of the other advantages are, as The Lopez mentioned, that it's easier to keep options for different mods separated. Also, I think non-programmers are a little less likely to be intimidated by and/or mess up an INI file than an XML file. If they do mess it up, it's also probably less likely that an error in an INI file will totally screw up the whole game.
I agree, it is less daunting for non-programmers to go into INI files and tune a mod.

Beyond that, there is also the chance that people will try to include the GlobalDefines.XML file in their mods instead of the suggested GlobalDefinesAlt.XML...
 
Back
Top Bottom