Alias

From P2SR Wiki

Revision as of 15:54, 27 October 2020 by BigDaniel (talk | contribs) (Created page with "{{P2_Title|Alias}} =Overview= <code>alias</code> is a console command that creates a new command. It takes two arguments, the first being the name of whatever command you ar...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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 change on
  • alias on "functionality; alias change off"
  • alias off "functionality; alias change on"
  • bind key change

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"
  • alias -action "functionality"
  • bind key +action

Common Examples

Video with common examples and explinations

These are examples I included in the Portal 2 Wiki 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 funneling_change "funneling_off"
  • alias funneling_off "sv_player_funnel_into_portals 0; sar_hud_text Portal Funneling OFF; alias funneling_change funneling_on"
  • alias funneling_on "sv_player_funnel_into_portals 1; sar_hud_text Portal Funneling ON; alias funneling_change funneling_off"

Ambient Light/Fullbright

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

Change alias that switches between different values of ambient light

  • alias ambient_change ambient_on
  • alias ambient_off "mat_ambient_light_b 0; mat_ambient_light_g 0; mat_ambient_light_r 0; alias ambient_change ambient_on"
  • alias ambient_on "mat_ambient_light_b .07; mat_ambient_light_g .07; mat_ambient_light_r .07; alias ambient_change ambient_off"

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 dialogue_change mutedialogue
  • alias mutedialogue "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; alias dialogue_change unmutedialogue"
  • alias unmutedialogue "snd_setmixer potatosVO vol 0.4;snd_setmixer gladosVO vol 0.7;snd_setmixer announcerVO vol 0.7;snd_setmixer wheatleyVO vol .7;snd_setmixer caveVO vol 0.88;snd_setmixer coreVO vol 0.75; alias dialogue_change mutedialogue"

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 duck_change +toggleduck
  • alias -toggleduck "-duck; alias duck_change +toggleduck"
  • alias +toggleduck "+duck; alias duck_change -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 sr_change sr_on
  • alias sr_off "bind mwheelup +jump; bind mwheeldown +jump; say no sr; alias sr_change sr_on"
  • alias sr_on "bind mwheelup +attack; bind mwheeldown +attack; say sr; alias sr_change sr_off"

Use Swap

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

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

  • alias +use_swap "bind mwheelup +use"
  • alias -use_swap "bind mwheelup +jump"

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"

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 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"