config file

Started by
7 comments, last by Doggan 18 years, 11 months ago
Can anyone explain to me what a config file is used for, and how you go about creating one?
Advertisement
do you mean a config file like many games use them?

if(yourAnswer == YES)
{
those files are used to store data even when the program is closed so that certain settings dont need to be made every time you rin your program. those setting could be screenresolution, texture quality, player name etc.
}
else
{
sorry i understood you wrong

}



greets DeviceLost

A config file is useful for providing a layer of abstraction between the game and the game code. Instead of hard-coding settings, they are stored in a text file which can be loaded at run-time. This eliminates the need to rebuild the game just to make a few tweaks to the settings.

It's not that important to have one for small, hobbyist projects like Pong or Tic-Tac-Toe, but for something as massive as an FPS, it's almost critical, as building the game's code-base can become a matter of hours.

As far as making one goes, you pretty much have to write your own parser. There is a somewhat-standard data-storage format known as XML, and I'm sure Googling for XML parsers will yield something useful.
If you're using windows there is some API functions for parsing .ini files. Maybe have a lookinto them. I think they called Get/SetProfileItem
Quote:Original post by chad_420
If you're using windows there is some API functions for parsing .ini files. Maybe have a lookinto them. I think they called Get/SetProfileItem


GetPrivateProfileString/WritePrivateProfileString ;-)
It's just a matter of having the Win32 help standing by or Google MSDN for the words :-)

A scripting language like Lua or Python can also be used. Both have code for parsing and manipulating scripts, and a typical Lua config script can look like this (that eliminates the sections of an ini, but can contain tables if wanted to give some sort of a class hierarchy, like the code shown below):
screen.width = 1024screen.height = 768


Then you can go further and use Lua scripting for your entire game, but that's another subject.
Killers don't end up in jailThey end up on a high-score!

What Dev IDE and Language are you using. As siad about in Windows there are some api functions that you can use to interact with ini files, but in .Net there are managed functions that will allow you to interact with Application Configuration Files. Also using the newer .Net 2.0 Framework you no longer have to access the registtory to store user daya as you can read and write from the app.config files using the new User Settings Sections.

Mykre - BlogVirtual Realm :- XNA News and Resources from Down Under** For those Interested in an Australian XNA User Group Contact me though my site.
Quote:Original post by Mykre

What Dev IDE and Language are you using. As siad about in Windows there are some api functions that you can use to interact with ini files, but in .Net there are managed functions that will allow you to interact with Application Configuration Files. Also using the newer .Net 2.0 Framework you no longer have to access the registtory to store user daya as you can read and write from the app.config files using the new User Settings Sections.


Or you could just use .NET's amazing XML support, which I think would be the way to go because of the flexibility. And it's just so easy to do with C#.
Thanks for response!
I'm writing my app in C++ in .NET
is an .ini file just a text file with that extension?
Quote:Original post by fooman_69
is an .ini file just a text file with that extension?


Yep. As with all extensions, they really have no set meaning (its a windows thing). Linux doesn't usually use them as you may notice. Name the file whatever you want, but .ini is usually the standard way to go for initialization settings.

This topic is closed to new replies.

Advertisement