Difference between revisions of "Alias"

From P2SR Wiki

(code blocks into pre, updated alias syntax)
(updated alias syntax (again))
Line 58: Line 58:
  
 
<pre>
 
<pre>
sar_hud_set_text 0 "Portal Funneling: OFF"
+
alias funnelingOff    "alias funnelingChange funnelingOn;  sv_player_funnel_into_portals 0; sar_hud_set_text 0 Portal Funneling: #FF5555OFF"
sar_hud_set_text 1 "Portal Funneling: ON"
+
alias funnelingOn    "alias funnelingChange funnelingOff; sv_player_funnel_into_portals 1; sar_hud_set_text 0 Portal Funneling: #55FF55ON"
alias funnelingOff    "alias funnelingChange funnelingOn;  sv_player_funnel_into_portals 0; sar_hud_show_text 0; sar_hud_hide_text 1"
 
alias funnelingOn    "alias funnelingChange funnelingOff; sv_player_funnel_into_portals 1; sar_hud_hide_text 0; sar_hud_show_text 1"
 
 
funnelingOn // on by default, replace with funnelingOff to be off by default
 
funnelingOn // on by default, replace with funnelingOff to be off by default
 
bind <key> funnelingChange
 
bind <key> funnelingChange

Revision as of 22:07, 2 June 2021

Alias

Overview

alias is a console command that creates a new command. It takes two arguments, the first being the name of whatever command you are creating, and the second argument are the other commands that will make up your new command. They are incredibly powerful, but are forgotten by the game upon closing, so they are perfect for an autoexec.

For example, alias "defaultviewmodel" "viewmodel_offset_x 0; viewmodel_offset_y 0; viewmodel_offset_z 0" creates a new command inside of Portal 2 called "defaultviewmodel", and typing this command will set all viewmodel offsets to 0.

Types of Examples

Standard Alias

You can add multiple functionalities to an alias, there is no limit, so long as the commands do not act as a script and follow the rules for both SRC and iVerb.

Format

alias name "functionality1; functionality2; etc"
bind key name

Change Commands

A change command is typically made of three aliases, and designed to be used as a one-key bind that toggles functionality by redefining the core alias.

Format

alias turnItOn  "functionality; alias changeIt turnItOff"
alias turnItOff "functionality; alias changeIt turnItOn"
turnItOn // either on or off, depending on what you want as default
bind <key> changeIt

Action Commands

An action command consists of two aliases of the same name, differentiated by the prefix + or -. Binding a key to the + variant will keep the functionality active while the button is held down. Releasing the key enacts the - variant.

Note: iVerb rules forbid binding of multiple actions to one key, including using aliases. Read more bellow.

iVerb Rules doc

Format

alias +action "functionality when pressed"
alias -action "functionality when released"
bind key +action

Common Examples

Video with common examples and explinations

Examples included in this video on execs:

Portal Funneling (Uses SAR)

  • 1st Press: Portal Funneling off, value written to sar_hud_text
  • 2nd Press: Portal Funneling on, value written to sar_hud_text

Change alias that swaps the values of Portal Funneling

alias funnelingOff    "alias funnelingChange funnelingOn;  sv_player_funnel_into_portals 0; sar_hud_set_text 0 Portal Funneling: #FF5555OFF"
alias funnelingOn     "alias funnelingChange funnelingOff; sv_player_funnel_into_portals 1; sar_hud_set_text 0 Portal Funneling: #55FF55ON"
funnelingOn // on by default, replace with funnelingOff to be off by default
bind <key> funnelingChange

Ambient Light/Fullbright

  • 1st Press: Ambient light for red, green and blue set to .07
  • 2nd Press: Ambient light for red, green and blue set to 0

Change alias that switches between different values of ambient light. Used to combat video compression on Turret Factory and sometimes Catapult Block.

alias ambientOff    "alias ambientChange ambientOn;  mat_ambient_light_r 0;   mat_ambient_light_g 0;   mat_ambient_light_b 0"
alias ambientOn     "alias ambientChange ambientOff; mat_ambient_light_r .07; mat_ambient_light_g .07; mat_ambient_light_b .07"
ambientOff // Off by default, replace with ambientOn to be on by default
bind <key> ambientChange

Dialogue

  • 1st Press: Lowers the dialogue for all main voice overs
  • 2nd Press: Brings the dialogue volume back to default levels

Change alias that toggles between making dialogue silent and bringing values back up to default

alias dialogueFull  "alias dialogueChange dialogueMute; snd_setmixer potatosVO vol .4;  snd_setmixer gladosVO vol .7;  snd_setmixer announcerVO vol .7;  snd_setmixer wheatleyVO vol .7;  snd_setmixer caveVO vol .88; snd_setmixer coreVO vol .75"
alias dialogueMute  "alias dialogueChange dialogueFull; snd_setmixer potatosVO vol .01; snd_setmixer gladosVO vol .01; snd_setmixer announcerVO vol .01; snd_setmixer wheatleyVO vol .01; snd_setmixer caveVO vol .01; snd_setmixer coreVO vol .01"
dialogueFull // replace with dialogueMute to be muted by default
bind <key> dialogueChange

Toggle duck

  • 1st Press: Player stays in a crouched position
  • 2nd Press: Player is taken out of crouched position

Change alias that toggles the duck functionality (crouching). Useful for Coop Any% runs.

alias -toggleDuck "alias toggleDuck +toggleDuck; -duck"
alias +toggleDuck "alias toggleDuck -toggleDuck; +duck"
-toggleDuck
bind <key> toggleDuck

Super Reportal

  • 1st Press: Both mouse wheels are switched to firing blue portals
  • 2nd Press: Both mouse wheels are switched to jumping.

Change alias that swaps between jumps on scroll wheel and portal shots. Use attack for blue portals, attack2 for orange, and change the default up and down to your liking of standard scroll binds.

alias srOff     "bind mwheelup +jump;   bind mwheeldown +jump;   say No SR; alias srChange srOn"
alias srOn      "bind mwheelup +attack; bind mwheeldown +attack; say SR;    alias srChange srOff"
srOff
bind <key> srChange

Use Swap

  • Held: Mouse wheel up is +use
  • Released: Mouse wheel up is +jump

Action alias that, while held, changes your mouse wheel up to +use, and when released, changes it back. Switch these values as you see fit for your binds.

alias +useSwap "bind mwheelup +use"
alias -useSwap "bind mwheelup +jump"
bind <key> +useSwap

Walk Key

  • Held: Player movement speed is moved from 175 to 84
  • Released: Player movement speed is moved from 84 to 175

Action alias that, while held, gives the player slower movement

Note: Challenge Mode has the cl speed commands cheat protected. They are allowed in Full game and AMC
alias +walk "cl_forwardspeed 84;  cl_backspeed 84;  cl_sidespeed 84"
alias -walk "cl_forwardspeed 175; cl_backspeed 175; cl_sidespeed 175"
bind <key> +walk

Viewmodel Commands

Allow you to easily hide/unhide viewmodel

alias showvm "viewmodel_offset_x 0; viewmodel_offset_y 0; viewmodel_offset_z 0"
alias hidevm "viewmodel_offset_x 0; viewmodel_offset_y 0; viewmodel_offset_z 100"

HUD Commands (Uses SAR)

Commands to add in a few SAR hud elements. sarhud uses the showinputs alias. The sar_hud values are set to replicate the values of cl_showpos.

alias showinputs "sar_ihud 3; sar_ihud_setpos bottom left; sar_ihud_button_color 255 255 255 255"
alias nosarhud   "sar_hud_velocity 0; sar_hud_position 0; sar_hud_angles 0; sar_ihud 0; sar_sr_hud 0"
alias sarhud     "sar_hud_default_font_index 1; sar_hud_default_padding_y 5; sar_hud_default_spacing 5; sar_hud_velocity 1; sar_hud_position 2; sar_hud_angles 2; sar_sr_hud 1; sar_sr_hud_y 120; showinputs"

Demo Viewing (Uses SAR)

Command to make demo viewing more seamless, and to undo those changes so that playing can resume after watching.

Note: Playing with sv_alternateticks 0 is banned. Only use it for demo watching
alias demo_viewer    "sv_alternateticks 0; cl_enable_remote_splitscreen 1; sar_disable_challenge_stats_hud 1; gameinstructor_enable 0"
alias no_demo_viewer "sv_alternateticks 1; sar_disable_challenge_stats_hud 0"