Portal 2 script functions
Jump to navigation
Jump to search
This table is adapted from the list generated by the script_help
console command. Any changes are welcome.
Function | Signature | Description |
---|---|---|
AddBranchLevelName | void AddBranchLevelName(int, string) | Adds a level to the specified branche's list. |
AddCoopCreditsName | void AddCoopCreditsName(string) | Adds a name to the coop credit's list. |
CBaseAnimating::GetAttachmentAngles | Vector CBaseAnimating::GetAttachmentAngles(int) | Get the attachement id's angles as a p,y,r vector |
CBaseAnimating::GetAttachmentOrigin | Vector CBaseAnimating::GetAttachmentOrigin(int) | Get the attachement id's origin vector |
CBaseAnimating::GetObjectScaleLevel | int CBaseAnimating::GetObjectScaleLevel() | The scale size of the entity |
CBaseAnimating::IsSequenceFinished | bool CBaseAnimating::IsSequenceFinished() | Ask whether the main sequence is done playing |
CBaseAnimating::LookupAttachment | int CBaseAnimating::LookupAttachment(string) | Get the named attachement id |
CBaseAnimating::SetBodygroup | void CBaseAnimating::SetBodygroup(int, int) | Sets a bodygroup |
CBaseEntity::ConnectOutput | void CBaseEntity::ConnectOutput(string, string) | Adds an I/O connection that will call the named function when the specified output fires |
CBaseEntity::Destroy | void CBaseEntity::Destroy() | |
CBaseEntity::DisconnectOutput | void CBaseEntity::DisconnectOutput(string, string) | Removes a connected script function from an I/O event. |
CBaseEntity::EmitSound | void CBaseEntity::EmitSound(string) | Plays a sound from this entity. |
CBaseEntity::EyePosition | Vector CBaseEntity::EyePosition() | Get vector to eye position - absolute coords |
CBaseEntity::FirstMoveChild | handle CBaseEntity::FirstMoveChild() | |
CBaseEntity::GetAngles | Vector CBaseEntity::GetAngles() | Get entity pitch, yaw, roll as a vector |
CBaseEntity::GetAngularVelocity | Vector CBaseEntity::GetAngularVelocity() | Get the local angular velocity - returns a vector of pitch,yaw,roll |
CBaseEntity::GetBoundingMaxs | Vector CBaseEntity::GetBoundingMaxs() | Get a vector containing max bounds, centered on object |
CBaseEntity::GetBoundingMins | Vector CBaseEntity::GetBoundingMins() | Get a vector containing min bounds, centered on object |
CBaseEntity::GetCenter | Vector CBaseEntity::GetCenter() | Get vector to center of object - absolute coords |
CBaseEntity::GetClassname | string CBaseEntity::GetClassname() | |
CBaseEntity::GetForwardVector | Vector CBaseEntity::GetForwardVector() | Get the forward vector of the entity |
CBaseEntity::GetHealth | int CBaseEntity::GetHealth() | |
CBaseEntity::GetLeftVector | Vector CBaseEntity::GetLeftVector() | Get the left vector of the entity |
CBaseEntity::GetMaxHealth | int CBaseEntity::GetMaxHealth() | |
CBaseEntity::GetModelKeyValues | handle CBaseEntity::GetModelKeyValues() | Get a KeyValue class instance on this entity's model |
CBaseEntity::GetModelName | string CBaseEntity::GetModelName() | Returns the name of the model |
CBaseEntity::GetMoveParent | handle CBaseEntity::GetMoveParent() | If in hierarchy, retrieves the entity's parent |
CBaseEntity::GetName | string CBaseEntity::GetName() | |
CBaseEntity::GetOrigin | Vector CBaseEntity::GetOrigin() | |
CBaseEntity::GetOwner | handle CBaseEntity::GetOwner() | Gets this entity's owner |
CBaseEntity::GetPreTemplateName | string CBaseEntity::GetPreTemplateName() | Get the entity name stripped of template unique decoration |
CBaseEntity::GetRootMoveParent | handle CBaseEntity::GetRootMoveParent() | If in hierarchy, walks up the hierarchy to find the root parent |
CBaseEntity::GetScriptId | string CBaseEntity::GetScriptId() | Retrieve the unique identifier used to refer to the entity within the scripting system |
CBaseEntity::GetScriptScope | handle CBaseEntity::GetScriptScope() | Retrieve the script-side data associated with an entity |
CBaseEntity::GetSoundDuration | float CBaseEntity::GetSoundDuration(string, string) | Returns float duration of the sound. Takes soundname and optional actormodelname. |
CBaseEntity::GetTeam | int CBaseEntity::GetTeam() | |
CBaseEntity::GetUpVector | Vector CBaseEntity::GetUpVector() | Get the up vector of the entity |
CBaseEntity::GetVelocity | Vector CBaseEntity::GetVelocity() | |
CBaseEntity::NextMovePeer | handle CBaseEntity::NextMovePeer() | |
CBaseEntity::PrecacheSoundScript | void CBaseEntity::PrecacheSoundScript(string) | Precache a sound for later playing. |
CBaseEntity::SetAbsOrigin | void CBaseEntity::SetAbsOrigin(Vector) | SetAbsOrigin |
CBaseEntity::SetAngles | void CBaseEntity::SetAngles(float, float, float) | Set entity pitch, yaw, roll |
CBaseEntity::SetAngularVelocity | void CBaseEntity::SetAngularVelocity(float, float, float) | Set the local angular velocity - takes float pitch,yaw,roll velocities |
CBaseEntity::SetForwardVector | void CBaseEntity::SetForwardVector(Vector) | Set the orientation of the entity to have this forward vector |
CBaseEntity::SetHealth | void CBaseEntity::SetHealth(int) | |
CBaseEntity::SetMaxHealth | void CBaseEntity::SetMaxHealth(int) | |
CBaseEntity::SetModel | void CBaseEntity::SetModel(string) | |
CBaseEntity::SetOrigin | void CBaseEntity::SetOrigin(Vector) | |
CBaseEntity::SetOwner | void CBaseEntity::SetOwner(handle) | Sets this entity's owner |
CBaseEntity::SetSize | void CBaseEntity::SetSize(Vector, Vector) | |
CBaseEntity::SetTeam | void CBaseEntity::SetTeam(int) | |
CBaseEntity::SetVelocity | void CBaseEntity::SetVelocity(Vector) | |
CBaseEntity::ValidateScriptScope | bool CBaseEntity::ValidateScriptScope() | Ensure that an entity's script scope has been created |
CBaseEntity::entindex | int CBaseEntity::entindex() | |
CBaseFlex::GetCurrentScene | handle CBaseFlex::GetCurrentScene() | Returns the instance of the oldest active scene entity (if any). |
CBaseFlex::GetSceneByIndex | handle CBaseFlex::GetSceneByIndex(int) | Returns the instance of the scene entity at the specified index. |
CBasePlayer::IsNoclipping | bool CBasePlayer::IsNoclipping() | Returns true if the player is in noclip mode. |
CEntities::CreateByClassname | handle CEntities::CreateByClassname(string) | Creates an entity by classname |
CEntities::FindByClassname | handle CEntities::FindByClassname(handle, string) | Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
CEntities::FindByClassnameNearest | handle CEntities::FindByClassnameNearest(string, Vector, float) | Find entities by class name nearest to a point. |
CEntities::FindByClassnameWithin | handle CEntities::FindByClassnameWithin(handle, string, Vector, float) | Find entities by class name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
CEntities::FindByModel | handle CEntities::FindByModel(handle, string) | Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
CEntities::FindByName | handle CEntities::FindByName(handle, string) | Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
CEntities::FindByNameNearest | handle CEntities::FindByNameNearest(string, Vector, float) | Find entities by name nearest to a point. |
CEntities::FindByNameWithin | handle CEntities::FindByNameWithin(handle, string, Vector, float) | Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
CEntities::FindByTarget | handle CEntities::FindByTarget(handle, string) | Find entities by targetname. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
CEntities::FindInSphere | handle CEntities::FindInSphere(handle, Vector, float) | Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search |
CEntities::First | handle CEntities::First() | Begin an iteration over the list of entities |
CEntities::Next | handle CEntities::Next(handle) | Continue an iteration over the list of entities, providing reference to a previously found entity |
CEnvEntityMaker::SpawnEntity | void CEnvEntityMaker::SpawnEntity() | Create an entity at the location of the maker |
CEnvEntityMaker::SpawnEntityAtEntityOrigin | void CEnvEntityMaker::SpawnEntityAtEntityOrigin(handle) | Create an entity at the location of a specified entity instance |
CEnvEntityMaker::SpawnEntityAtLocation | void CEnvEntityMaker::SpawnEntityAtLocation(Vector, Vector) | Create an entity at a specified location and orientaton, orientation is Euler angle in degrees (pitch, yaw, roll) |
CEnvEntityMaker::SpawnEntityAtNamedEntityOrigin | void CEnvEntityMaker::SpawnEntityAtNamedEntityOrigin(string) | Create an entity at the location of a named entity |
CLinkedPortalDoor::GetPartnerInstance | handle CLinkedPortalDoor::GetPartnerInstance() | Get the instance handle of the door's linked partner |
CLinkedPortalDoor::GetPartnername | string CLinkedPortalDoor::GetPartnername() | Returns the partnername of the door. |
CPlayerVoiceListener::GetPlayerSpeechDuration | float CPlayerVoiceListener::GetPlayerSpeechDuration(int) | Returns the number of seconds the player has been continuously speaking. |
CPlayerVoiceListener::IsPlayerSpeaking | bool CPlayerVoiceListener::IsPlayerSpeaking(int) | Returns whether the player specified is speaking. |
CPortal_Player:: GetWheatleyMonitorDestructionCount |
int CPortal_Player::GetWheatleyMonitorDestructionCount() | Get number of wheatley monitors destroyed by the player. |
CPortal_Player:: IncWheatleyMonitorDestructionCount |
void CPortal_Player::IncWheatleyMonitorDestructionCount() | Set number of wheatley monitors destroyed by the player. |
CPortal_Player::TurnOffPotatos | void CPortal_Player::TurnOffPotatos() | Turns Off the Potatos material light |
CPortal_Player::TurnOnPotatos | void CPortal_Player::TurnOnPotatos() | Turns On the Potatos material light |
CPropLinkedPortalDoor::GetPartnerInstance | handle CPropLinkedPortalDoor::GetPartnerInstance() | Get the instance handle of the door's linked partner |
CPropLinkedPortalDoor::GetPartnername | string CPropLinkedPortalDoor::GetPartnername() | Returns the partnername of the door. |
CSceneEntity::AddBroadcastTeamTarget | void CSceneEntity::AddBroadcastTeamTarget(int) | Adds a team (by index) to the broadcast list |
CSceneEntity::EstimateLength | float CSceneEntity::EstimateLength() | Returns length of this scene in seconds. |
CSceneEntity::FindNamedEntity | handle CSceneEntity::FindNamedEntity(string) | given an entity reference, such as !target, get actual entity from scene object |
CSceneEntity::IsPaused | bool CSceneEntity::IsPaused() | If this scene is currently paused. |
CSceneEntity::IsPlayingBack | bool CSceneEntity::IsPlayingBack() | If this scene is currently playing. |
CSceneEntity::LoadSceneFromString | bool CSceneEntity::LoadSceneFromString(string, string) | given a dummy scene name and a vcd string, load the scene |
CSceneEntity::RemoveBroadcastTeamTarget | void CSceneEntity::RemoveBroadcastTeamTarget(int) | Removes a team (by index) from the broadcast list |
CScriptKeyValues::FindKey | handle CScriptKeyValues::FindKey(string) | Given a KeyValues object and a key name, find a KeyValues object associated with the key name |
CScriptKeyValues::GetFirstSubKey | handle CScriptKeyValues::GetFirstSubKey() | Given a KeyValues object, return the first sub key object |
CScriptKeyValues::GetKeyBool | bool CScriptKeyValues::GetKeyBool(string) | Given a KeyValues object and a key name, return associated bool value |
CScriptKeyValues::GetKeyFloat | float CScriptKeyValues::GetKeyFloat(string) | Given a KeyValues object and a key name, return associated float value |
CScriptKeyValues::GetKeyInt | int CScriptKeyValues::GetKeyInt(string) | Given a KeyValues object and a key name, return associated integer value |
CScriptKeyValues::GetKeyString | string CScriptKeyValues::GetKeyString(string) | Given a KeyValues object and a key name, return associated string value |
CScriptKeyValues::GetNextKey | handle CScriptKeyValues::GetNextKey() | Given a KeyValues object, return the next key object in a sub key group |
CScriptKeyValues::IsKeyEmpty | bool CScriptKeyValues::IsKeyEmpty(string) | Given a KeyValues object and a key name, return true if key name has no value |
CScriptKeyValues::ReleaseKeyValues | void CScriptKeyValues::ReleaseKeyValues() | Given a root KeyValues object, release its contents |
CTriggerCamera::GetFov | int CTriggerCamera::GetFov() | get camera's current fov setting as integer |
CTriggerCamera::SetFov | void CTriggerCamera::SetFov(int, float) | set camera's current fov in integer degrees and fov change rate as float |
CreateProp | handle CreateProp(string, Vector, string, int) | Create a physics prop |
CreateSceneEntity | handle CreateSceneEntity(string) | Create a scene entity to play the specified scene. |
DebugDrawBox | void DebugDrawBox(Vector, Vector, Vector, int, int, int, int, float) | Draw a debug overlay box |
DebugDrawLine | void DebugDrawLine(Vector, Vector, int, int, int, bool, float) | Draw a debug overlay box |
DoIncludeScript | bool DoIncludeScript(string, handle) | Execute a script (internal) |
EntFire | function EntFire(target, action, value, delay, activator) | Generate and entity i/o event |
EntFireByHandle | void EntFireByHandle(handle, string, string, float, handle, handle) | Generate and entity i/o event. First parameter is an entity instance. |
FrameTime | float FrameTime() | Get the time spent on the server in the last frame |
GetBluePlayerIndex | int GetBluePlayerIndex() | Player index of the blue player. |
GetCoopBranchLevelIndex | int GetCoopBranchLevelIndex(int) | Given the 'branch' argument, returns the current chosen level. |
GetCoopSectionIndex | int GetCoopSectionIndex() | Section that the coop players have selected to load. |
GetDeveloperLevel | int GetDeveloperLevel() | Gets the level of 'develoer' |
GetHighestActiveBranch | int GetHighestActiveBranch() | Returns which branches should be available in the hub. |
GetMapIndexInPlayOrder | int 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. |
GetMapName | string GetMapName() | Get the name of the map. |
GetNumMapsPlayed | int GetNumMapsPlayed() | Returns how many maps the player has played through. |
GetOrangePlayerIndex | int GetOrangePlayerIndex() | Player index of the orange player. |
GetPlayer | handle GetPlayer() | Returns the player (SP Only). |
GetPlayerSilenceDuration | float GetPlayerSilenceDuration(int) | Time that the specified player has been silent on the mic. |
GivePlayerPortalgun | void GivePlayerPortalgun() | Give player the portalgun. |
IsLevelComplete | bool IsLevelComplete(int, int) | Returns true if the level in the specified branch is completed by either player. |
IsMultiplayer | bool IsMultiplayer() | Is this a multiplayer game? |
IsPlayerLevelComplete | bool IsPlayerLevelComplete(int, int, int) | Returns true if the level in the specified branch is completed by a specific player. |
LoopSinglePlayerMaps | bool LoopSinglePlayerMaps() | Run the single player maps in a continuous loop. |
MarkMapComplete | void MarkMapComplete(string) | Marks a maps a complete for both players. |
PrecacheMovie | void PrecacheMovie(string) | Precaches a named movie. Only valid to call within the entity's 'Precache' function called on mapspawn. |
RandomFloat | float RandomFloat(float, float) | Generate a random floating point number within a range, inclusive |
RandomInt | int RandomInt(int, int) | Generate a random integer within a range, inclusive |
RecordAchievementEvent | void RecordAchievementEvent(string, int) | Records achievement event or progress |
RequestMapRating | void RequestMapRating() | Pops up the map rating dialog for user input |
ScriptShowHudMessageAll | void ScriptShowHudMessageAll(string, float) | Show center print text message. |
ScriptSteamShowURL | bool ScriptSteamShowURL(string) | Bring up the steam overlay and shows the specified URL. (Full address with protocol type is required, e.g. http://www.steamgames.com/) |
SendToConsole | void SendToConsole(string) | Send a string to the console as a command |
SetDucking | void SetDucking(string, string, float) | Set the level of an audio ducking channel |
SetMapAsPlayed | int 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. |
ShowMessage | void ShowMessage(string) | Print a hud message on all clients |
Time | float Time() | Get the current server time |
TraceLine | float TraceLine(Vector, Vector, handle) | given 2 points & ent to ignore, return fraction along line that hits world or models |
TryDLC1InstalledOrCatch | bool TryDLC1InstalledOrCatch() | Tests if the DLC1 is installed for Try/Catch blocks. |
UniqueString | function UniqueString(string) | 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. |
UpgradePlayerPortalgun | void UpgradePlayerPortalgun() | Give player the portalgun. |
UpgradePlayerPotatogun | void UpgradePlayerPotatogun() | Give player the portalgun. |