Config+
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.
Language Overview
The basics of Config+ is to expand on Portal 2's base developer console, introducing commands like cond
and conds
, which run commands based on conditions, and sar_on_*
events, which run commands based on certain in-game events.
Conditions
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.
Condition | Description |
---|---|
map=
|
Checks whether the player is in a certain map. prev_map= and 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
|
coop
|
Checks whether the player is in a co-op gamemode |
orange
|
Checks whether the player is playing as P-Body (Orange) in co-op |
cm
|
Checks whether the player is in Challenge Mode (individual level speedruns) |
workshop
|
Checks whether the player is in a workshop/custom map |
menu
|
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.
sar_on_*
Many of the sar_on_*
commands are listed below. When creating more advanced command chains, these would often times be the most used.
sar_on_* | Description |
---|---|
load
|
To be run on session start (map load, loading a save, etc.) |
session_end
|
To be run on session end |
exit
|
To be run on game exit |
flags
|
To be run when Challenge Mode flags/ending are hit |
pb
|
To be run when automatic run submission detects a personal best |
not_pb
|
To be run when the automatic run submission detects not a personal best |
Putting things together
sar_on_*
and 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.
Config++
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_alias
/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_add
, svar_sub
, svar_mul
, svar_div
, and svar_mod
, with appropriate svar_f...
versions for floating point arithmetic. There are also more traditional math functions for svars including svar_floor
, svar_round
, svar_ceil
(ceiling), 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_alias
and 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
Config++ Projects
Using aliases, functions, and svars, multiple complex projects can be created.
Project | Description |
---|---|
srconfigs | A set of config files for Portal 2 speedrunning built using Config+ and Config++ commands |
SARtris | A re-creation of Tetris using Config++ commands, including features like 7-bag piece rotation and holding |
Brainfuck Interpreter | A Brainfuck interpreter built entirely using Config++ commands |