Difference between revisions of ".cfg Files"

From P2SR Wiki

(Created page with "{{P2_Title| Config Files (.cfg)}} =Overview= A config file is a file that stores commands for your game. In Portal 2, the game has many config files that it keeps track of fo...")
 
(formatting, linux -nojoy, foolproof syntax for exec)
 
Line 1: Line 1:
{{P2_Title| Config Files (.cfg)}}
+
{{P2_Title|Config Files (.cfg)}}
 
 
 
=Overview=
 
=Overview=
 
A config file is a file that stores commands for your game. In Portal 2, the game has many config files that it keeps track of for a variety of different purposes. As users, we can create config files that contain any commands we want.
 
A config file is a file that stores commands for your game. In Portal 2, the game has many config files that it keeps track of for a variety of different purposes. As users, we can create config files that contain any commands we want.
 
 
=Execution=
 
=Execution=
 
 
The execution order for config files in Portal 2 goes as follows
 
The execution order for config files in Portal 2 goes as follows
 
+
# The <code>autoexec.cfg</code> is ran at startup, and is the first config file loaded.
# The autoexec.cfg is ran at startup, and is the first config file loaded.
+
# The <code>config.cfg</code> file is ran after, and loads in all of your saved binds and settings that carry over.
# The config.cfg file is ran after, and loads in all of your saved binds and settings that carry over.
+
This means that the [[Autoexec]] is not a good place to put binds. They will be overwritten by your <code>config.cfg</code> file after the game loads. If you intend on setting up custom binds, enter them manually in console, or in an exec that is run separately.  
 
 
This means that the [[Autoexec]] is not a good place to put binds. They will be overwritten by your config.cfg file after the game loads. If you intend on setting up custom binds, enter them manually in console, or in an exec that is run separately.  
 
 
 
 
==Executing a .cfg file==
 
==Executing a .cfg file==
To exec a .cfg file, it must be located in Portal 2's installation folder (usually <code>C:\Program Files (x86)\Steam\steamapps\common\Portal 2\portal2\cfg</code>)
+
To execute a <code>.cfg</code> file, it must be located in Portal 2's config folder (usually <code>C:\Program Files (x86)\Steam\steamapps\common\Portal 2\portal2\cfg</code>)
 
+
The file named <code>autoexec.cfg</code> will execute on game launch, any other config you make will need to be manually executed in the Portal 2 console. If the <code>autoexec.cfg</code> file doesn't exist, you can create it yourself by renaming and replacing the extension of a <code>.txt</code> file.
The file named <code>autoexec.cfg</code> will exec on game launch, any other exec you make will need to be manually executed as such in the Portal 2 console.:
 
 
 
*<code>exec filename</code>
 
 
 
''You do not need to include the .cfg extension when executing''
 
  
 +
'''WRONG:'''
 +
<pre style="color:red">exec filename.cfg</pre>
 +
'''RIGHT:'''
 +
<pre style="color:green">exec filename</pre>
 
=Useful Tools=
 
=Useful Tools=
 
 
==Filtering Out Junk Text==
 
==Filtering Out Junk Text==
 
+
There are a few error messages or warning in the Source Engine that aren't useful, and will constantly fill up your console with garbage text, the command <code>con_filter_enable 1</code> allows you to filter out specific strings from appearing in your console.
There are a few error messages or warning in the Source Engine that aren't useful, and will constantly fill up your console with garbage text, the command '''con_filter_enable 1''' allows you to filter out specific strings from appearing in your console.
 
  
 
A common use of this filter is for CShader warning messages that fill your console with constant messages. Filtering it in your autoexec is simple. In the example below, any line with the text <code>CShader</code> is filtered out, but you can replace this with any string.
 
A common use of this filter is for CShader warning messages that fill your console with constant messages. Filtering it in your autoexec is simple. In the example below, any line with the text <code>CShader</code> is filtered out, but you can replace this with any string.
 
+
con_filter_enable 1
<code>con_filter_enable 1</code>
+
con_filter_text_out CShader
 
+
''On Linux, there are junk console messages that appear every few seconds about controller configurations. To remove this message (and also remove controller controls), add <code>-nojoy</code> to your game's Launch Options in Steam.''
<code>con_filter_text_out "CShader"</code>
+
[[Category:File]]
 
 
[[Category:file]]
 

Latest revision as of 22:45, 15 August 2021

Config Files (.cfg)

Overview

A config file is a file that stores commands for your game. In Portal 2, the game has many config files that it keeps track of for a variety of different purposes. As users, we can create config files that contain any commands we want.

Execution

The execution order for config files in Portal 2 goes as follows

  1. The autoexec.cfg is ran at startup, and is the first config file loaded.
  2. The config.cfg file is ran after, and loads in all of your saved binds and settings that carry over.

This means that the Autoexec is not a good place to put binds. They will be overwritten by your config.cfg file after the game loads. If you intend on setting up custom binds, enter them manually in console, or in an exec that is run separately.

Executing a .cfg file

To execute a .cfg file, it must be located in Portal 2's config folder (usually C:\Program Files (x86)\Steam\steamapps\common\Portal 2\portal2\cfg) The file named autoexec.cfg will execute on game launch, any other config you make will need to be manually executed in the Portal 2 console. If the autoexec.cfg file doesn't exist, you can create it yourself by renaming and replacing the extension of a .txt file.

WRONG:

exec filename.cfg

RIGHT:

exec filename

Useful Tools

Filtering Out Junk Text

There are a few error messages or warning in the Source Engine that aren't useful, and will constantly fill up your console with garbage text, the command con_filter_enable 1 allows you to filter out specific strings from appearing in your console.

A common use of this filter is for CShader warning messages that fill your console with constant messages. Filtering it in your autoexec is simple. In the example below, any line with the text CShader is filtered out, but you can replace this with any string.

con_filter_enable 1
con_filter_text_out CShader

On Linux, there are junk console messages that appear every few seconds about controller configurations. To remove this message (and also remove controller controls), add -nojoy to your game's Launch Options in Steam.