CFG: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(Change the description quite a bit, I also added a Common CFGs section for adding known .cfg files like modsettings.cfg.)
No edit summary
 
(46 intermediate revisions by 16 users not shown)
Line 1: Line 1:
{{otherlang2
{{LanguageBar}}
|de=CFG:de
}}
{{DISPLAYTITLE:cfg}}
'''.cfg''' files can be found everywhere and are not specific to [[Source]]. It is an abbreviation of ''configuration''.


'''Configuration file''' (or '''CFG''') is a {{src|4}} games text file used to [[exec]]ute a newline-delimited list of [[ConCommand|console command]]s to the [[Developer Console]]. The '''.cfg''' file extension can be found everywhere and is not specific to Source.


In Source games, a configuration file can be executed to perform a list of console commands. CFG files can be written in any other plain [[text editor]]. To create one, right-click the blank space in a cfg folder, and go to <code>New>Text file</code>. Rename it to <code>myconfig.cfg</code> or whatever you want, as long as it ends in .cfg and is placed in the cfg folder. You can then open it in your text editor and put commands in.  Normally, the file <code>autoexec.cfg</code> is run when the game starts up, so you can easily put any commands that you don't want to enter each time into that.  They can also be ran from the console using "<code>exec <cfgname></code>" where filename is the name of the configuration file, with or without the extension. Sometimes people put exec lines into the <code>autoexec.cfg</code>, so that other cfg files are executed when the game starts up. Configuration files can be placed in subdirectories of the cfg folder. The exec command would require you to include the subdirectories in the command.
{{tip|It can be useful to keep situational key[[bind]]s in files other than autoexec.cfg.}}


{{tip|You can add comments to .cfg files by using // .}}
{{ModernConfirm|What exactly happens after exec autoexec.cfg.}}


== Common CFGs ==
== File format ==
This is a table listing common .cfg files found in mods and games alike.
* Each line is considered a command. Note that each command can still consist of multiple commands delimited with the semicolon <code>;</code>.
* Comments can be added by using <code>//</code>. These two characters and everything following after them is ignored by the engine until the next line starts.
* Cheat commands require {{Command|sv_cheats|1}} enabled, otherwise they have no effect. To configure a mod's default cheat convars, [[VScript]] or {{Ent|point_servercommand}} can achieve this on map start without having to enable sv_cheats.
 
==Files==
 
The folder <code><game>/cfg/</code> is usually dedicated to CFG files and can be further organized in subdirectories, and referred in {{Command|exec}} by [[W:Path_(computing)#Absolute_and_relative_paths|relative path]].
 
This is a table listing common CFG files found in mods and games alike.


{| class="wikitable"
{| class="wikitable"
! CFG !! Description
! CFG !! Description
|-
|-
| '''[[autoexec|autoexec.cfg]]''' || Ran on game start up.
| '''[[autoexec|autoexec.cfg]]''' || Ran on game start up, so one can easily create the file and put any commands that one doesn't want to type each time.
|-
|-
| '''modsettings.cfg''' || Ran every time a map is loaded.
| '''chapter#.cfg''' || Ran when the player picks the chapter, with # being the chapter number, see [[Adding chapters to your mod]].
|-
|-
| '''config.cfg''' || Ran on game start up, this is created automatically when the player runs the game/mod for the first time.
| '''config.cfg''' || Ran on game start up, this is created automatically when the player runs the game/mod for the first time. {{note| On game quit, key binds in this file will be re-written to current bindings, so making changes to this file is most likely pointless.}}
|-
|-
| '''config_default.cfg''' || Ran when no config.cfg is present or the player clicks the 'Use Defaults' button in the keyboard tab in the options panel, see [[Customizing Options: Keyboard]].
| '''[[Customizing_Options:_Keyboard#cfg.2Fconfig_default.cfg|config_default.cfg]]''' || Ran when no config.cfg is present or when player clicks the 'Use Defaults' button in the keyboard tab in the options panel, see [[Customizing Options: Keyboard]].
|-
|-
| '''chapter#.cfg''' || Ran when the player picks the chapter, with # being the chapter number, see [[Adding chapters to your mod]].
| '''360controller.cfg''' || Used for players using {{360|2}} {{xone|2}}, {{xbseries|1}} (or XInput-compatible) controllers, lists the controls for the controller. Automatically executed when player enable Gamepad support in game options.
{{Note|Gamepad option (referred as Legacy gamepad support) in Options menu was removed in {{hl2|1}} since 20th Anniversary Update. However the {{code|joystick}} [[ConVar]] still works and can be enabled.}}
|-
|-
| '''game.cfg''' || Ran on game start up.
| '''360controller-linux.cfg''' || Used for players using {{360|2}}, {{xone|2}}, {{xbseries|1}} (or XInput-compatible) controllers on Linux systems, lists the controls for the controller. {{confirm|executed after 360controller.cfg.}}
|-
|-
| '''sourcevr_modfoldername.cfg''' || {{2013 add}} Ran when the player enables VR, replace modnamefolder with the name of your folder that [[gameinfo.txt]] is in.
| '''undo360controller.cfg''' || Used for players using {{360|2}}, {{xone|2}}, {{xbseries|1}} (or XInput-compatible) controllers when they want to undo the effects of the controller. {{todo|Find out when this is executed.}}
|-
|-
| '''skill_manifest.cfg''' || Ran on game start up, used to list the skill.cfgs to execute.
| '''game.cfg''' || Ran every time a map is loaded.
|-
|-
| '''360controller.cfg''' || Used for players using XBox 360 controllers, lists the controls for the controller. {{TODO|Find out when this is executed.}}
| '''listenserver.cfg''' || Ran when a listen server is being started, and runs every time the map is changed.
|-
|-
| '''360controller-linux.cfg''' || Used for players using XBox 360 controllers on Linux systems, executed after 360controller.cfg, lists the controls for the controller.
| '''modsettings.cfg''' || Ran on game start up, unless not found in mod folder.
|-
|-
| '''undo360controller.cfg''' || Used for players using XBox 360 controllers when they want to undo the effects of the controller. {{TODO|Find out when this is executed.}}
| '''server.cfg''' || Ran when a dedicated server is being started, and runs every time the map is changed.
|-
|-
| '''listenserver.cfg''' || Ran when a listen server is being started, and runs every time the map is changed.
| '''skill_manifest.cfg''' || Runs every time the map is changed, used to list the skill.cfgs to execute.
|-
| '''sourcevr_modfoldername.cfg''' || {{src13|since}} Ran when the player enables VR, replace modfoldername with the name of your folder that [[gameinfo.txt]] is in.
|-
|-
| '''server.cfg''' || Ran when a dedicated server is being started, and runs every time the map is changed.
| '''userconfig.cfg''' || Ran on game start up, for "custom configurations", as a comment in config.cfg describes it. The pre-Steam version of Half-Life does not load it automatically, and users place configurations in autoexec.cfg instead. ([https://wiki.sourceruns.org/wiki/Setting_up_userconfig_file rumor])
|-
|-
| '''[[valve.rc]]''' || Special cfg file with the .rc extension, it's ran on game start up and executes autoexec.cfg along with a few other commands.
| '''[[valve.rc]]''' || Special cfg file with the .rc extension, it's ran on game start up and executes autoexec.cfg along with a few other commands.
|-
|}
|}
== See also ==
 
==See also==
* [[Mini-mod tutorial]]
* [[Mini-mod tutorial]]
* [[vtest]] - Alternative to cfg files.
* [[vtest]] - Alternative to cfg files.
* {{Command|alias}}
* {{Command|echo}}


== External links ==
[[Category:Plain text formats]]
* [http://filext.com/detaillist.php?extdetail=cfg&goButton=Go More information on the format]
[[Category:Plain text files]]
 
[[Category:File formats]]
[[Category:File formats]]
[[Category:Glossary]]
[[Category:Source]]

Latest revision as of 06:34, 10 February 2025

English (en)Deutsch (de)Translate (Translate)

Configuration file (or CFG) is a Source Source games text file used to execute a newline-delimited list of console commands to the Developer Console. The .cfg file extension can be found everywhere and is not specific to Source.

Tip.pngTip:It can be useful to keep situational keybinds in files other than autoexec.cfg.
Confirm:What exactly happens after exec autoexec.cfg.

File format

  • Each line is considered a command. Note that each command can still consist of multiple commands delimited with the semicolon ;.
  • Comments can be added by using //. These two characters and everything following after them is ignored by the engine until the next line starts.
  • Cheat commands require sv_cheats 1 enabled, otherwise they have no effect. To configure a mod's default cheat convars, VScript or point_servercommand can achieve this on map start without having to enable sv_cheats.

Files

The folder <game>/cfg/ is usually dedicated to CFG files and can be further organized in subdirectories, and referred in exec by relative path.

This is a table listing common CFG files found in mods and games alike.

CFG Description
autoexec.cfg Ran on game start up, so one can easily create the file and put any commands that one doesn't want to type each time.
chapter#.cfg Ran when the player picks the chapter, with # being the chapter number, see Adding chapters to your mod.
config.cfg Ran on game start up, this is created automatically when the player runs the game/mod for the first time.
Note.pngNote: On game quit, key binds in this file will be re-written to current bindings, so making changes to this file is most likely pointless.
config_default.cfg Ran when no config.cfg is present or when player clicks the 'Use Defaults' button in the keyboard tab in the options panel, see Customizing Options: Keyboard.
360controller.cfg Used for players using Xbox 360 Xbox 360 Xbox One Xbox One, Xbox Series X/S (or XInput-compatible) controllers, lists the controls for the controller. Automatically executed when player enable Gamepad support in game options.
Note.pngNote:Gamepad option (referred as Legacy gamepad support) in Options menu was removed in Half-Life 2 since 20th Anniversary Update. However the joystick ConVar still works and can be enabled.
360controller-linux.cfg Used for players using Xbox 360 Xbox 360, Xbox One Xbox One, Xbox Series X/S (or XInput-compatible) controllers on Linux systems, lists the controls for the controller.
Confirm:executed after 360controller.cfg.
undo360controller.cfg Used for players using Xbox 360 Xbox 360, Xbox One Xbox One, Xbox Series X/S (or XInput-compatible) controllers when they want to undo the effects of the controller.
Todo: Find out when this is executed.
game.cfg Ran every time a map is loaded.
listenserver.cfg Ran when a listen server is being started, and runs every time the map is changed.
modsettings.cfg Ran on game start up, unless not found in mod folder.
server.cfg Ran when a dedicated server is being started, and runs every time the map is changed.
skill_manifest.cfg Runs every time the map is changed, used to list the skill.cfgs to execute.
sourcevr_modfoldername.cfg (in all games since Source 2013) Ran when the player enables VR, replace modfoldername with the name of your folder that gameinfo.txt is in.
userconfig.cfg Ran on game start up, for "custom configurations", as a comment in config.cfg describes it. The pre-Steam version of Half-Life does not load it automatically, and users place configurations in autoexec.cfg instead. (rumor)
valve.rc Special cfg file with the .rc extension, it's ran on game start up and executes autoexec.cfg along with a few other commands.

See also