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

Globals

ActivatePaint

Activates the specified paint power on all players.

void ActivatePaint(int paintType)

AddBranchLevelName

Adds a level to the specified branch's list.

void AddBranchLevelName(int branch, string levelName)

AddCoopCreditsName

Adds a name to the coop credits list.

void AddCoopCreditsName(string name)

CreateEntityByName

Create entity by classname, setting the specified key values before spawn.

handle CreateEntityByName(string className, table entKeyVals)

CreateProp

Create a physics prop, setting the specified model name and activity index. Prefer CreateEntityByName() for more flexibility.

handle CreateProp(string classname, Vector origin, string modelName, int activityIndex)

CreateSceneEntity

Create a scene entity to play the specified scene.

handle CreateSceneEntity(string filename)

DeactivateAllPaints

Deactivates all the paints on all players.

void DeactivateAllPaints()

DeactivatePaint

Deactivates the specified paint power on all players.

void DeactivatePaint(int paintType)

DebugDrawBox

Draw a debug overlay box.

void DebugDrawBox(Vector origin, Vector mins, Vector maxes, int r, int g, int b, int a, float duration)

DebugDrawBoxAngles

Draw a debug overlay box with angles/

void DebugDrawBoxAngles(Vector origin, Vector mins, Vector maxes, Vector angles, int r, int g, int b, int a, float duration)

DebugDrawEntityText

Draw debug overlay entity text.

void DebugDrawEntityText(int entityID, int textOffset, string text, float duration, int r, int g, int b, int a)

DebugDrawEntityTextAtPosition

Draw a debug overlay entity text at position.

void DebugDrawEntityTextAtPosition(Vector origin, int textOffset, string text, float duration, int r, int g, int b, int a)

DebugDrawGrid

Draw debug overlay grid.

void DebugDrawGrid(Vector origin)

DebugDrawLine

Draw a debug overlay line.

void DebugDrawLine(Vector p1, Vector p2, int r, int g, int b, bool noDepthTest, float duration)

DebugDrawScreenText

Draw debug overlay screen text.

void DebugDrawScreenText(float x, float y, string text, int r, int g, int b, int a, float duration)

DebugDrawText

Draw debug overlay text.

void DebugDrawText(Vector origin, string text, bool viewCheck, float duration)

DebugDrawTri

Draw a debug overlay triangle.

void DebugDrawTri(Vector p1, Vector p2, Vector p3, int r, int g, int b, int a, bool noDepthTest, float duration)

DispatchParticleEffect

Dispatches a one-off particle system, automatically cleaned up once finished.

void DispatchParticleEffect(string particleName, Vector origin, Vector angles)

DoIncludeScript

Implementation of IncludeScript(), use that instead.

bool DoIncludeScript(string filename, table scope)

EntFire

Generate an entity i/o event, searching by entity name.

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

EntFireByHandle

Generate an entity i/o event, directly targeting an entity by reference.

void EntFireByHandle(entity target, string input, string parameter, float delay, entity activator, entity caller)

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 linkageID, int portalNum)

FrameTime

Get the time spent on the server in the last frame

float FrameTime()

GetBluePlayerIndex

Return the player index of the blue player.

int GetBluePlayerIndex()

GetCoopBranchLevelIndex

Returns the current chosen level in the hub.

int GetCoopBranchLevelIndex(int branch)

GetCoopSectionIndex

Section that the coop players have selected to load in the hub.

int GetCoopSectionIndex()

GetDeveloperLevel

Gets the level of the 'developer' console variable.

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

Return the 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 playerIndex)

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 player)

GivePlayerPaintgun

Gives all portal players the paint gun with no active paints.

void GivePlayerPaintgun()

GivePlayerPortalgun

Give player a monoportal portal gun.

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 branch, int level)

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 player, int branch, int level)

LoopSinglePlayerMaps

Run the single player maps in a continuous loop.

bool LoopSinglePlayerMaps()

MarkMapComplete

Marks a map as complete for both players.

void MarkMapComplete(string mapName)

PrecacheMovie

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

void PrecacheMovie(string movieName)

RandomFloat

Generate a random floating point number within a range, inclusive

float RandomFloat(float min, float max)

RandomInt

Generate a random integer within a range, inclusive

int RandomInt(int min, int max)

RecordAchievementEvent

Records achievement event or progress.

void RecordAchievementEvent(string achievement, int playerIndex)

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 message)

ScriptPrintMessageCenterAllWithParams

Prints an alert message in the center print method to all players, substituting parameters. Can pass null for parameters if you need less than 3.

void ScriptPrintMessageCenterAllWithParams(string message, string param1, string param2, string param3)

ScriptPrintMessageCenterTeam

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

void ScriptPrintMessageCenterTeam(int team, string message)

ScriptPrintMessageChatAll

Prints a message in chat to all players.

void ScriptPrintMessageChatAll(string message)

ScriptPrintMessageChatTeam

Prints a message in chat to the specified team.

void ScriptPrintMessageChatTeam(int team, string message)

ScriptShowHudMessageAll

Show center print text message.

void ScriptShowHudMessageAll(string message, float holdTime)

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 url)

SendToConsole

Execute the specified console command, as if run by the local player or server host.

void SendToConsole(string command)

SendToConsoleServer

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

void SendToConsoleServer(string command)

SendToPanorama

Send an event to Panorama.

void SendToPanorama(string eventName, string payload)

SetDucking

Set the level of an audio ducking channel

void SetDucking(string layer, string mixGroup, float factor)

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 message)

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 start, Vector end, Vector hullMin, Vector hullMax, int mask, entity entToIgnore, int collisionGroup)

TraceLine

Trace a line, then return the fraction along line that hits world or models.

float TraceLine(Vector start, Vector end, entity entToIgnore)

TraceLineEx

Given 2 points, ent to ignore (or array of ents to ignore), collision group and trace mask, returns a CGameTrace with the result.

handle TraceLineEx(Vector start, Vector end, int mask, object ignore, int collisionGroup)

TraceLinePlayersIncluded

Trace a line, then return the fraction along line that hits world, models, players or npcs.

float TraceLinePlayersIncluded(Vector start, Vector end, entity entToIgnore)

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 start, Vector end, int mask, object ignore, int collisionGroup, bool transformTrace)

TryDLC1InstalledOrCatch

Always returns true. Used in Portal 2 to test if DLC1 was installed.

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(object string)

UpgradePlayerPaintgun

Upgrades the paint gun of all players, if they are not holding one it will give them one.

void UpgradePlayerPaintgun()

UpgradePlayerPortalgun

Upgrade the player's held gun to shoot both portals.

void UpgradePlayerPortalgun()

UpgradePlayerPotatogun

Add Potatos to the player's held portal gun, and force it to be a dual device.

void UpgradePlayerPotatogun()