Limited support
This feature is only present in Portal 2: Community Edition and Portal: Revolution.

Globals

ActivatePaint

Activates the specified paint power on the player.

void ActivatePaint(int)

AddBranchLevelName

Adds a level to the specified branche's list.

void AddBranchLevelName(int, string)

AddCoopCreditsName

Adds a name to the coop credit's list.

void AddCoopCreditsName(string)

CreateEntityByName

(string className, table entKeyVals) - Create entity by class string with specified key values

handle CreateEntityByName(string, handle)

CreateProp

Create a physics prop

handle CreateProp(string, Vector, string, int)

CreateSceneEntity

Create a scene entity to play the specified scene.

handle CreateSceneEntity(string)

DeactivateAllPaints

Deactivates all the paints on the player.

void DeactivateAllPaints()

DeactivatePaint

Deactivates the specified paint power on the player.

void DeactivatePaint(int)

DebugDrawBox

Draw a debug overlay box

void DebugDrawBox(Vector, Vector, Vector, int, int, int, int, float)

DebugDrawBoxAngles

Draw a debug overlay box with angles

void DebugDrawBoxAngles(Vector, Vector, Vector, Vector, int, int, int, int, float)

DebugDrawEntityText

Draw debug overlay entity text

void DebugDrawEntityText(int, int, string, float, int, int, int, int)

DebugDrawEntityTextAtPosition

Draw a debug overlay entity text at position

void DebugDrawEntityTextAtPosition(Vector, int, string, float, int, int, int, int)

DebugDrawGrid

Draw debug overlay grid

void DebugDrawGrid(Vector)

DebugDrawLine

Draw a debug overlay box

void DebugDrawLine(Vector, Vector, int, int, int, bool, float)

DebugDrawScreenText

Draw debug overlay screen text

void DebugDrawScreenText(float, float, string, int, int, int, int, float)

DebugDrawText

Draw debug overlay text

void DebugDrawText(Vector, string, bool, float)

DebugDrawTri

Draw a debug overlay triangle

void DebugDrawTri(Vector, Vector, Vector, int, int, int, int, bool, float)

DispatchParticleEffect

Dispatches a one-off particle system

void DispatchParticleEffect(string, Vector, Vector)

DoIncludeScript

Execute a script (internal)

bool DoIncludeScript(string, handle)

EntFire

Generate and entity i/o event

function EntFire(target, action, value, delay, activator)

EntFireByHandle

Generate and entity i/o event. First parameter is an entity instance.

void EntFireByHandle(handle, string, string, float, handle, handle)

FindPortalByID

Finds a portal by linkage ID and portal number. Portal number 1 is the primary portal, 2 is the secondary. Linkage ID should be <255

handle FindPortalByID(int, int)

FrameTime

Get the time spent on the server in the last frame

float FrameTime()

GetBluePlayerIndex

Player index of the blue player.

int GetBluePlayerIndex()

GetCoopBranchLevelIndex

Given the 'branch' argument, returns the current chosen level.

int GetCoopBranchLevelIndex(int)

GetCoopSectionIndex

Section that the coop players have selected to load.

int GetCoopSectionIndex()

GetDeveloperLevel

Gets the level of 'developer'

int GetDeveloperLevel()

GetHighestActiveBranch

Returns which branches should be available in the hub.

int GetHighestActiveBranch()

GetMapIndexInPlayOrder

Determines which index (by order played) this map is. Returns -1 if entry is not found. -2 if this is not a known community map.

int GetMapIndexInPlayOrder()

GetMapName

Get the name of the map.

string GetMapName()

GetNumMapsPlayed

Returns how many maps the player has played through.

int GetNumMapsPlayed()

GetOrangePlayerIndex

Player index of the orange player.

int GetOrangePlayerIndex()

GetPlayer

Returns the player (SP Only).

handle GetPlayer()

GetPlayerByIndex

Gets the player by their index. This is a one-based index and must be in the range (1 <= index <= GetPlayerCount())

handle GetPlayerByIndex(int)

GetPlayerCount

Returns the number of connected clients, this will always be 1 for listen servers

int GetPlayerCount()

GetPlayerSilenceDuration

Time that the specified player has been silent on the mic.

float GetPlayerSilenceDuration(int)

GivePlayerPaintgun

Give player the paintgun with no paints active.

void GivePlayerPaintgun()

GivePlayerPortalgun

Give player the portalgun.

void GivePlayerPortalgun()

IsCoOp

Is this a co-op game?

bool IsCoOp()

IsLevelComplete

Returns true if the level in the specified branch is completed by either player.

bool IsLevelComplete(int, int)

IsMultiplayer

Is this a multiplayer game?

bool IsMultiplayer()

IsPlayerLevelComplete

Returns true if the level in the specified branch is completed by a specific player.

bool IsPlayerLevelComplete(int, int, int)

LoopSinglePlayerMaps

Run the single player maps in a continuous loop.

bool LoopSinglePlayerMaps()

MarkMapComplete

Marks a maps a complete for both players.

void MarkMapComplete(string)

PrecacheMovie

Precaches a named movie. Only valid to call within the entity's 'Precache' function called on mapspawn.

void PrecacheMovie(string)

RandomFloat

Generate a random floating point number within a range, inclusive

float RandomFloat(float, float)

RandomInt

Generate a random integer within a range, inclusive

int RandomInt(int, int)

RecordAchievementEvent

Records achievement event or progress

void RecordAchievementEvent(string, int)

RequestMapRating

Pops up the map rating dialog for user input

void RequestMapRating()

ScriptIsLocalPlayerUsingController

Is the local player using a controller?

bool ScriptIsLocalPlayerUsingController()

ScriptPrintMessageCenterAll

Prints an alert message in the center print method to all players.

void ScriptPrintMessageCenterAll(string)

ScriptPrintMessageCenterAllWithParams

Prints an alert message in the center print method to all players. Needs to pass token/message. param1, param2, param3. Can pass null if you need less than 3.

void ScriptPrintMessageCenterAllWithParams(string, string, string, string)

ScriptPrintMessageCenterTeam

Prints an alert message in the center print method to the specified team.

void ScriptPrintMessageCenterTeam(int, string)

ScriptPrintMessageChatAll

Prints a message in chat to all players.

void ScriptPrintMessageChatAll(string)

ScriptPrintMessageChatTeam

Prints a message in chat to the specified team.

void ScriptPrintMessageChatTeam(int, string)

ScriptShowHudMessageAll

Show center print text message.

void ScriptShowHudMessageAll(string, float)

ScriptSteamShowURL

Bring up the steam overlay and shows the specified URL. (Full address with protocol type is required, e.g. http://www.steamgames.com/ )

bool ScriptSteamShowURL(string)

SendToConsole

Send a string to the console as a command

void SendToConsole(string)

SendToConsoleServer

Send a string that gets executed on the server as a ServerCommand

void SendToConsoleServer(string)

SendToPanorama

Send an event to Panorama

void SendToPanorama(string, string)

SetDucking

Set the level of an audio ducking channel

void SetDucking(string, string, float)

SetMapAsPlayed

Adds the current map to the play order and returns the new index therein. Returns -2 if this is not a known community map.

int SetMapAsPlayed()

ShowMessage

Print a hud message on all clients

void ShowMessage(string)

Time

Get the current server time

float Time()

TraceHull

Sweeps a hull along the specified line. Returns a CGameTrace with the trace result

handle TraceHull(Vector, Vector, Vector, Vector, int, handle, int)

TraceLine

given 2 points & ent to ignore, return fraction along line that hits world or models

float TraceLine(Vector, Vector, handle)

TraceLineEx

Given 2 points, ent to ignore, collision group and trace mask, returns a CGameTrace with the result

handle TraceLineEx(Vector, Vector, int, handle, int)

TraceLinePlayersIncluded

given 2 points & ent to ignore, return fraction along line that hits world, models, players or npcs

float TraceLinePlayersIncluded(Vector, Vector, handle)

TracePortalLine

Same as TraceLineEx, but will transform the trace based on any portals it passes through. If the last bool is true, it will transform based on the first portal it went though.

handle TracePortalLine(Vector, Vector, int, handle, int, bool)

TryDLC1InstalledOrCatch

Tests if the DLC1 is installed for Try/Catch blocks.

bool TryDLC1InstalledOrCatch()

UniqueString

Generate a string guaranteed to be unique across the life of the script VM, with an optional root string. Useful for adding data to tables when not sure what keys are already in use in that table.

function UniqueString(string)

UpgradePlayerPaintgun

Upgrades the players paintgun, if they are not holding one it will give them one.

void UpgradePlayerPaintgun()

UpgradePlayerPortalgun

Give player the portalgun.

void UpgradePlayerPortalgun()

UpgradePlayerPotatogun

Give player the portalgun.

void UpgradePlayerPotatogun()