Config+ is an esoteric programming language built inside of the game Portal 2 using the custom plugin SourceAutoRecord as a base. SourceAutoRecord (also known as SAR) is a plugin mainly built for speedrunners to have some quality-of-life features in-game, including an in-game timer, reduced loading times, and configurable text HUDS, among other things. Inside of SAR is also Config+, a feature built mainly to expand on Portal 2's developer console, introducing variables, functions, and more.
The basics of Config+ is to expand on Portal 2's base developer console, introducing commands like
conds, which run commands based on conditions, and
sar_on_* events, which run commands based on certain in-game events.
cond commands take both a condition and command, which only gets ran once the condition is met. A few of the most useful conditions are listed below.
|Checks whether the player is in a certain map.
same_map both also exist to check whether the previous map is a specific map, or if the previous map is the same as the current map
|Checks whether the player is in a co-op gamemode
|Checks whether the player is playing as P-Body (Orange) in co-op
|Checks whether the player is in Challenge Mode (individual level speedruns)
|Checks whether the player is in a workshop/custom map
|Checks whether the player is in a certain map
There are also logical expressions, like
! for NOT,
& for AND, and
| for OR.
As well, if-else statements can be ran using the
conds command, which takes one condition argument and two command arguments, the first of which gets ran when the argument is true, the second when the argument is false.
Many of the
sar_on_* commands are listed below. When creating more advanced command chains, these would often times be the most used.
|To be run on session start (map load, loading a save, etc.)
|To be run on session end
|To be run on game exit
|To be run when Challenge Mode flags/ending are hit
|To be run when automatic run submission detects a personal best
|To be run when the automatic run submission detects not a personal best
Putting things together
cond can be used together to create more complex commands. For example:
sar_on_load cond map=sp_a2_laser_chaining "echo Hello World!"
will run on session start (loading a map or save), check to see if the player is on the map sp_a2_laser_chaining, and if that's true, print "Hello World!" into the developer console.
More advanced usage of Config+ for "less than intended" purposes is referred to Config++. Usage of Config++ compared to standard Config+ comes from using SAR variables, or svars, and
sar_function, which is allows the user to write out custom commands and functions.
SAR Variables (svars)
SAR variables (styled as svar) are custom variables that the user can create that can either hold a custom value, or read a value from a base Portal 2 command. svar's can be defined using the
svar_set command, with arguments for the svar name and value. As well,
svar_capture can be used, replacing the value from svar_set with a command to read the output from, or
svar_from_cvar to read the value of an already existing in-game variable.
Arithmetic can be done on svars using commands like
svar_mod, with appropriate
svar_f... versions for floating point arithmetic. There are also more traditional math functions for svars including
svar_abs (absolute value), and
svar_substr which sets the value of an svar its substring.
svars can be read using
? before the svar name inside a condition, for example:
svar_set test 1 conds ?test=1 "Test is set to 1" "Test is not set to 1"
SAR Aliases and Functions
sar_function allow the user to define their own custom commands to be ran in console. The major difference between the two commands is that
sar_function allows the user to define arguments as well.
Aliases can be defined as such:
sar_alias aliasname "map sp_a2_laser_chaining;echo Map changed to Laser Chaining"
aliasname can now be ran in console, and the two commands defined in the alias (separated by
;) will be ran.
Functions are similarly defined:
sar_function print echo "$1" print "Hello World!"
$1 refers to the argument passed by the user, and can be expanded to support multiple arguments.
svars can also be read through functions:
sar_function print "$variable" svar_set variable "Hello World!" print
Using aliases, functions, and svars, multiple complex projects can be created.
|A set of config files for Portal 2 speedrunning built using Config+ and Config++ commands
|A re-creation of Tetris using Config++ commands, including features like 7-bag piece rotation and holding
|A Brainfuck interpreter built entirely using Config++ commands