This article relates to the game "Portal 2". Click here for more information.
This article relates to "Squirrel". Click here for more information.

Portal 2/Scripting/Script Functions: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
m (remove unnessacary spaces)
 
(36 intermediate revisions by 15 users not shown)
Line 1: Line 1:
{{sq}} This list contains all engine-related Squirrel functions available for [[VScript]] in {{game link|Portal 2}}. It can be printed in-game with the <code>scipt_help</code> command while running in [[Engine tools|tools mode]].
{{lang|List of Portal 2 Script Functions|title=List of ''​Portal 2​'' Script Functions}}
{{p2 topicon}}{{SQ topicon}}
{{toc-right}}


== [[CBaseAnimating]] ==
This list contains all engine-related Squirrel functions available for [[VScript]] in {{Portal2|4}}. It can be printed in-game with the <code>script_help</code> command while running in [[Engine tools|tools mode]].
{| class="standard-table" style="width: 100%;"
 
! Function
== Variables ==
! Signature
{| class="standard-table"
! Description
!Instance
!Type
!Description
|-
|<code>Entities</code>
|<code>[[#CEntities|CEntities]]</code>
|Provides access to spawned entities in the server.
|-
|}
 
 
== Constants ==
{| class="standard-table"
!Instance
!Type
!Value
|-
|-
| <code>GetAttachmentAngles</code>
|<code>_charsize_</code>
| <code>Vector CBaseAnimating::GetAttachmentAngles(int)</code>
|integer
| Get the attachement id's angles as a p,y,r vector
| 1
|-
|-
| <code>GetAttachmentOrigin</code>
|<code>_floatsize_</code>
| <code>Vector CBaseAnimating::GetAttachmentOrigin(int)</code>
|integer
| Get the attachement id's origin vector
| 4
|-
|-
| <code>GetObjectScaleLevel</code>
|<code>_intsize_</code>
| <code>int CBaseAnimating::GetObjectScaleLevel()</code>
|integer
| The scale size of the entity
| 4
|-
|-
| <code>IsSequenceFinished</code>
|<code>_version_</code>
| <code>bool CBaseAnimating::IsSequenceFinished()</code>
|string
| Ask whether the main sequence is done playing
| "Squirrel 2.2.3 stable"
|-
|-
| <code>LookupAttachment</code>
|<code>RAND_MAX</code>
| <code>int CBaseAnimating::LookupAttachment(string)</code>
|integer
| Get the named attachement id
| 32767
|-
|-
| <code>SetBodygroup</code>
|<code>PI</code>
| <code>void CBaseAnimating::SetBodygroup(int, int)</code>
|float
| Sets a bodygroup
| 3.14159
|}
|}




== [[CBaseEntity]] ==
== Classes ==
 
 
=== CBaseEntity ===
This is a script handle class for entities. All entities spawned have a script handle using this or one of its subclasses.
 
All script handles in-game are accessible from [[#CEntities|Entities]]. Entity scripts can use <code>self</code> to access their own script handle. <code>activator</code> and <code>caller</code> variables can be accessed on function calls.
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
! Signature
! Signature
! Description
! Description
|-
| <code>__KeyValueFromInt</code>
| <code>void __KeyValueFromInt(string ''key'', int ''value'')</code>
| Sets an entity [[Keyvalue]] from an integer. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
|-
| <code>__KeyValueFromFloat</code>
| <code>void __KeyValueFromFloat(string ''key'', float ''value'')</code>
| Sets an entity Keyvalue from a float. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
|-
| <code>__KeyValueFromString</code>
| <code>void __KeyValueFromString(string ''key'', string ''value'')</code>
| Sets an entity Keyvalue from a string. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
|-
| <code>__KeyValueFromVector</code>
| <code>void __KeyValueFromVector(string ''key'', Vector ''value'')</code>
| Sets an entity Keyvalue from a [[#Vector|Vector]]. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
|-
|-
| <code>ConnectOutput</code>
| <code>ConnectOutput</code>
| <code>void CBaseEntity::ConnectOutput(string, string)</code>
| <code>void CBaseEntity::ConnectOutput(string output, string func_name)</code>
| Adds an I/O connection that will call the named function when the specified output fires
| Adds an I/O connection that will call the named function when the specified output fires.
|-
|-
| <code>Destroy</code>
| <code>Destroy</code>
| <code>void CBaseEntity::Destroy()</code>
| <code>void CBaseEntity::Destroy()</code>
| Kill this entity.
|-
|-
| <code>DisconnectOutput</code>
| <code>DisconnectOutput</code>
| <code>void CBaseEntity::DisconnectOutput(string, string)</code>
| <code>void CBaseEntity::DisconnectOutput(string output, string func_name)</code>
| Removes a connected script function from an I/O event.
| Removes a connected script function from an I/O event.
|-
|-
| <code>EmitSound</code>
| <code>EmitSound</code>
| <code>void CBaseEntity::EmitSound(string)</code>
| <code>void CBaseEntity::EmitSound(string sound)</code>
| Plays a sound from this entity.
| Plays a sound from this entity.
|-
|-
| <code>EyePosition</code>
| <code>EyePosition</code>
| <code>Vector CBaseEntity::EyePosition()</code>
| <code>Vector CBaseEntity::EyePosition()</code>
| Get vector to eye position - absolute coords
| Get vector to eye position - absolute coords.
|-
|-
| <code>FirstMoveChild</code>
| <code>FirstMoveChild</code>
| <code>handle CBaseEntity::FirstMoveChild()</code>
| <code>handle CBaseEntity::FirstMoveChild()</code>
| If in hierarchy, get the first move child.
|-
|-
| <code>GetAngles</code>
| <code>GetAngles</code>
| <code>Vector CBaseEntity::GetAngles()</code>
| <code>Vector CBaseEntity::GetAngles()</code>
| Get entity pitch, yaw, roll as a vector
| Get entity pitch, yaw, roll as a vector.
|-
|-
| <code>GetAngularVelocity</code>
| <code>GetAngularVelocity</code>
| <code>Vector CBaseEntity::GetAngularVelocity()</code>
| <code>Vector CBaseEntity::GetAngularVelocity()</code>
| Get the local angular velocity - returns a vector of pitch,yaw,roll
| Get the local angular velocity - returns a vector of pitch,yaw,roll.
|-
|-
| <code>GetBoundingMaxs</code>
| <code>GetBoundingMaxs</code>
| <code>Vector CBaseEntity::GetBoundingMaxs()</code>
| <code>Vector CBaseEntity::GetBoundingMaxs()</code>
| Get a vector containing max bounds, centered on object
| Get a vector containing max bounds, centered on object.
|-
|-
| <code>GetBoundingMins</code>
| <code>GetBoundingMins</code>
| <code>Vector CBaseEntity::GetBoundingMins()</code>
| <code>Vector CBaseEntity::GetBoundingMins()</code>
| Get a vector containing min bounds, centered on object
| Get a vector containing min bounds, centered on object.
|-
|-
| <code>GetCenter</code>
| <code>GetCenter</code>
| <code>Vector CBaseEntity::GetCenter()</code>
| <code>Vector CBaseEntity::GetCenter()</code>
| Get vector to center of object - absolute coords
| Get vector to center of object - absolute coords.
|-
|-
| <code>GetClassname</code>
| <code>GetClassname</code>
| <code>string CBaseEntity::GetClassname()</code>
| <code>string CBaseEntity::GetClassname()</code>
| Get the classname of this entity.
|-
|-
| <code>GetForwardVector</code>
| <code>GetForwardVector</code>
| <code>Vector CBaseEntity::GetForwardVector()</code>
| <code>Vector CBaseEntity::GetForwardVector()</code>
| Get the forward vector of the entity
| Get the forward vector (+X) of the entity.
|-
|-
| <code>GetHealth</code>
| <code>GetHealth</code>
| <code>int CBaseEntity::GetHealth()</code>
| <code>int CBaseEntity::GetHealth()</code>
| Returns the current [[health]].
|-
|-
| <code>GetLeftVector</code>
| <code>GetLeftVector</code>
| <code>Vector CBaseEntity::GetLeftVector()</code>
| <code>Vector CBaseEntity::GetLeftVector()</code>
| Get the left vector of the entity
| Get the left vector of the entity.
|-
|-
| <code>GetMaxHealth</code>
| <code>GetMaxHealth</code>
| <code>int CBaseEntity::GetMaxHealth()</code>
| <code>int CBaseEntity::GetMaxHealth()</code>
| Returns the maximum health.
|-
|-
| <code>GetModelKeyValues</code>
| <code>GetModelKeyValues</code>
| <code>handle CBaseEntity::GetModelKeyValues()</code>
| <code>handle CBaseEntity::GetModelKeyValues()</code>
| Get a KeyValue class instance on this entity's model
| Get a KeyValue class instance on this entity's model.
|-
|-
| <code>GetModelName</code>
| <code>GetModelName</code>
| <code>string CBaseEntity::GetModelName()</code>
| <code>string CBaseEntity::GetModelName()</code>
| Returns the name of the model
| Returns the name of the model.
|-
|-
| <code>GetMoveParent</code>
| <code>GetMoveParent</code>
| <code>handle CBaseEntity::GetMoveParent()</code>
| <code>handle CBaseEntity::GetMoveParent()</code>
| If in hierarchy, retrieves the entity's parent
| If in hierarchy, retrieves the entity's parent.
|-
|-
| <code>GetName</code>
| <code>GetName</code>
| <code>string CBaseEntity::GetName()</code>
| <code>string CBaseEntity::GetName()</code>
|
| Get the Targetname of this entity.
|-
|-
| <code>GetOrigin</code>
| <code>GetOrigin</code>
| <code>Vector CBaseEntity::GetOrigin()</code>
| <code>Vector CBaseEntity::GetOrigin()</code>
|
| Returns this entity's local origin.
|-
|-
| <code>GetOwner</code>
| <code>GetOwner</code>
| <code>handle CBaseEntity::GetOwner()</code>
| <code>handle CBaseEntity::GetOwner()</code>
| Gets this entity's owner
| Gets this entity's owner.
|-
|-
| <code>GetPreTemplateName</code>
| <code>GetPreTemplateName</code>
| <code>string CBaseEntity::GetPreTemplateName()</code>
| <code>string CBaseEntity::GetPreTemplateName()</code>
| Get the entity name stripped of template unique decoration
| Get the entity name stripped of template unique decoration - the &001 suffix.
|-
|-
| <code>GetRootMoveParent</code>
| <code>GetRootMoveParent</code>
Line 132: Line 179:
| <code>GetScriptId</code>
| <code>GetScriptId</code>
| <code>string CBaseEntity::GetScriptId()</code>
| <code>string CBaseEntity::GetScriptId()</code>
| Retrieve the unique identifier used to refer to the entity within the scripting system
| Retrieve the unique identifier used to refer to the entity within the scripting system.
|-
|-
| <code>GetScriptScope</code>
| <code>GetScriptScope</code>
| <code>handle CBaseEntity::GetScriptScope()</code>
| <code>handle CBaseEntity::GetScriptScope()</code>
| Retrieve the script-side data associated with an entity
| Retrieve the script-side data associated with an entity.
|-
|-
| <code>GetSoundDuration</code>
| <code>GetSoundDuration</code>
Line 144: Line 191:
| <code>GetTeam</code>
| <code>GetTeam</code>
| <code>int CBaseEntity::GetTeam()</code>
| <code>int CBaseEntity::GetTeam()</code>
|
| Get the team this entity is on.
|-
|-
| <code>GetUpVector</code>
| <code>GetUpVector</code>
| <code>Vector CBaseEntity::GetUpVector()</code>
| <code>Vector CBaseEntity::GetUpVector()</code>
| Get the up vector of the entity
| Get the up vector (+Z) of the entity.
|-
|-
| <code>GetVelocity</code>
| <code>GetVelocity</code>
| <code>Vector CBaseEntity::GetVelocity()</code>
| <code>Vector CBaseEntity::GetVelocity()</code>
|
| Get the velocity of the entity. Note that this reads the [[QPhysics]] velocity value, so it only works for players, NPCs and moving brush entities. VPhysics objects always have a velocity of zero. A workaround is to record the position over multiple frames, and derive the velocity manually.
|-
| <code>IsValid</code>
| <code>bool CBaseEntity::IsValid()</code>
| Returns true if this entity is valid.
|-
|-
| <code>NextMovePeer</code>
| <code>NextMovePeer</code>
| <code>handle CBaseEntity::NextMovePeer()</code>
| <code>handle CBaseEntity::NextMovePeer()</code>
|
| Return the next entity in the same movement hierarchy.
|-
|-
| <code>PrecacheSoundScript</code>
| <code>PrecacheSoundScript</code>
| <code>void CBaseEntity::PrecacheSoundScript(string)</code>
| <code>void CBaseEntity::PrecacheSoundScript(string)</code>
| Precache a sound for later playing.
| Precache a sound for later playing. Should be called in the 'Precache()' hook function.
|-
|-
| <code>SetAbsOrigin</code>
| <code>SetAbsOrigin</code>
| <code>void CBaseEntity::SetAbsOrigin(Vector)</code>
| <code>void CBaseEntity::SetAbsOrigin(Vector)</code>
| SetAbsOrigin
| Teleport the entity to this world position.
|-
|-
| <code>SetAngles</code>
| <code>SetAngles</code>
Line 176: Line 227:
| <code>SetForwardVector</code>
| <code>SetForwardVector</code>
| <code>void CBaseEntity::SetForwardVector(Vector)</code>
| <code>void CBaseEntity::SetForwardVector(Vector)</code>
| Set the orientation of the entity to have this forward vector
| Set the orientation of the entity to have this forward (+X) vector.
|-
|-
| <code>SetHealth</code>
| <code>SetHealth</code>
| <code>void CBaseEntity::SetHealth(int)</code>
| <code>void CBaseEntity::SetHealth(int)</code>
|
| Sets the current [[health]].
|-
|-
| <code>SetMaxHealth</code>
| <code>SetMaxHealth</code>
| <code>void CBaseEntity::SetMaxHealth(int)</code>
| <code>void CBaseEntity::SetMaxHealth(int)</code>
|
| Sets the maximum health.
|-
|-
| <code>SetModel</code>
| <code>SetModel</code>
| <code>void CBaseEntity::SetModel(string)</code>
| <code>void CBaseEntity::SetModel(string)</code>
|
| Change the model used for the entity. This can be used to change models for prop_weighted_cube or other similar entities. The model must be precached, which is usually done by placing it elsewhere in the map.
|-
|-
| <code>SetOrigin</code>
| <code>SetOrigin</code>
| <code>void CBaseEntity::SetOrigin(Vector)</code>
| <code>void CBaseEntity::SetOrigin(Vector)</code>
|
| Teleport this entity to the given location.
|-
|-
| <code>SetOwner</code>
| <code>SetOwner</code>
| <code>void CBaseEntity::SetOwner(handle)</code>
| <code>void CBaseEntity::SetOwner(handle)</code>
| Sets this entity's owner
| Sets this entity's owner.
|-
|-
| <code>SetSize</code>
| <code>SetSize</code>
| <code>void CBaseEntity::SetSize(Vector, Vector)</code>
| <code>void CBaseEntity::SetSize(Vector, Vector)</code>
|
| Sets the bounding box size.
|-
|-
| <code>SetTeam</code>
| <code>SetTeam</code>
| <code>void CBaseEntity::SetTeam(int)</code>
| <code>void CBaseEntity::SetTeam(int)</code>
|
| Set the team this entity is on.
|-
|-
| <code>SetVelocity</code>
| <code>SetVelocity</code>
| <code>void CBaseEntity::SetVelocity(Vector)</code>
| <code>void CBaseEntity::SetVelocity(Vector)</code>
| Set local velocity.  Note that this sets the [[QPhysics]] velocity value, so it only works for players, NPCs and moving brush entities. On VPhysics objects, this has no effect.
|-
|-
| <code>ValidateScriptScope</code>
| <code>ValidateScriptScope</code>
| <code>bool CBaseEntity::ValidateScriptScope()</code>
| <code>bool CBaseEntity::ValidateScriptScope()</code>
| Ensure that an entity's script scope has been created
| Ensure that an entity's script scope has been created. This should be called before assigning to the entity's scope.
|-
|-
| <code>entindex</code>
| <code>entindex</code>
| <code>int CBaseEntity::entindex()</code>
| <code>int CBaseEntity::entindex()</code>
|
| Returns the entity index.
|}
 
=== CBaseAnimating ===
Extends [[#CBaseEntity|CBaseEntity]]
 
Script handle class for animating entities such as props.
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>GetAttachmentAngles</code>
| <code>Vector CBaseAnimating::GetAttachmentAngles(int id)</code>
| Get the attachment id's angles as a p,y,r vector.
|-
| <code>GetAttachmentOrigin</code>
| <code>Vector CBaseAnimating::GetAttachmentOrigin(int id)</code>
| Get the attachment id's origin vector
|-
| <code>GetObjectScaleLevel</code>
| <code>int CBaseAnimating::GetObjectScaleLevel()</code>
| The scale size of the entity
|-
| <code>IsSequenceFinished</code>
| <code>bool CBaseAnimating::IsSequenceFinished()</code>
| Ask whether the main sequence is done playing
|-
| <code>LookupAttachment</code>
| <code>int CBaseAnimating::LookupAttachment(string)</code>
| Get the ID for the named attachment.
|-
| <code>SetBodygroup</code>
| <code>void CBaseAnimating::SetBodygroup(int group, int index)</code>
| Sets a bodygroup. Group is the index for the desired group, and index is the desired part to use.
|}
|}


== [[CBaseFlex]] ==
 
=== CBaseFlex ===
Extends [[#CBaseAnimating|CBaseAnimating]]
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 233: Line 327:
|}
|}


== [[CBasePlayer]] ==
 
=== CBasePlayer ===
Extends [[#CBaseAnimating|CBaseAnimating]]
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 244: Line 343:
|}
|}


== CEntities ==
 
=== CEntities ===
Script instance: <code>Entities</code>
 
An interface to find and iterate over the script handles for the entities in play.
 
To iterate over a set of entities, pass <code>null</code> to the ''previous'' argument in the appropriate method to start an iteration, or reference to a previously found entity to continue a search. Example:
<source lang=cpp>
//The first way
local ent = null;    //The variable name "ent" is arbitrary.
while(ent = Entities.FindByName(ent, "entityname"))    //Indeed, we mean '=' and not '==' ! The loop aborts if "ent" becomes null.
{
  //...    //In every iteration, "ent" is not null.
}
 
//The second way
for(local ent;ent = Entities.FindByName(ent, "entityname");)    //The variable name "ent" is arbitrary. Indeed, we mean '=' and not '==' ! The loop aborts if "ent" becomes null. (All the semicolons are correctly placed)
{
  //...    //In every iteration, "ent" is not null.
}
</source>
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 255: Line 377:
|-
|-
| <code>FindByClassname</code>
| <code>FindByClassname</code>
| <code>handle CEntities::FindByClassname(handle, string)</code>
| <code>handle CEntities::FindByClassname(handle start_ent, string classname)</code>
| Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
|-
|-
| <code>FindByClassnameNearest</code>
| <code>FindByClassnameNearest</code>
| <code>handle CEntities::FindByClassnameNearest(string, Vector, float)</code>
| <code>handle CEntities::FindByClassnameNearest(string classname, Vector loc, float radius)</code>
| Find entities by class name nearest to a point.
| Find entities by class name nearest to a point.
|-
|-
| <code>FindByClassnameWithin</code>
| <code>FindByClassnameWithin</code>
| <code>handle CEntities::FindByClassnameWithin(handle, string, Vector, float)</code>
| <code>handle CEntities::FindByClassnameWithin(handle start_ent, string classname, Vector loc, float radius)</code>
| 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
| 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
|-
|-
| <code>FindByModel</code>
| <code>FindByModel</code>
| <code>handle CEntities::FindByModel(handle, string)</code>
| <code>handle CEntities::FindByModel(handle start_ent, string model)</code>
| Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
|-
|-
| <code>FindByName</code>
| <code>FindByName</code>
| <code>handle CEntities::FindByName(handle, string)</code>
| <code>handle CEntities::FindByName(handle start_ent, string targetname)</code>
| Find entities by name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by name (including wildcards). Pass 'null' to start an iteration, or reference to a previously found entity to continue a search.
|-
|-
| <code>FindByNameNearest</code>
| <code>FindByNameNearest</code>
| <code>handle CEntities::FindByNameNearest(string, Vector, float)</code>
| <code>handle CEntities::FindByNameNearest(string targetname, Vector loc, float radius)</code>
| Find entities by name nearest to a point.
| Find entities by name nearest to a point.
|-
|-
| <code>FindByNameWithin</code>
| <code>FindByNameWithin</code>
| <code>handle CEntities::FindByNameWithin(handle, string, Vector, float)</code>
| <code>handle CEntities::FindByNameWithin(handle, string, Vector loc, float radius)</code>
| Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
|-
|-
| <code>FindByTarget</code>
| <code>FindByTarget</code>
| <code>handle CEntities::FindByTarget(handle, string)</code>
| <code>handle CEntities::FindByTarget(handle start_ent, string targetname)</code>
| Find entities by targetname. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities with a specific <code>target</code> keyvalue. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
|-
|-
| <code>FindInSphere</code>
| <code>FindInSphere</code>
| <code>handle CEntities::FindInSphere(handle, Vector, float)</code>
| <code>handle CEntities::FindInSphere(handle start_ent, Vector loc, float radius)</code>
| Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
| Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
|-
|-
| <code>First</code>
| <code>First</code>
| <code>handle CEntities::First()</code>
| <code>handle CEntities::First()</code>
| Begin an iteration over the list of entities
| Begin an iteration over the list of entities. Equivalent to Next(null).
|-
|-
| <code>Next</code>
| <code>Next</code>
| <code>handle CEntities::Next(handle)</code>
| <code>handle CEntities::Next(handle)</code>
| Continue an iteration over the list of entities, providing reference to a previously found entity
| Continue an iteration over the list of entities, providing reference to a previously found entity.
|}
|}


== CEnvEntityMaker ==
 
=== CEnvEntityMaker ===
Extends [[#CBaseEntity|CBaseEntity]]
 
Script handle class for [[env_entity_maker]].
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 322: Line 451:
|}
|}


== CLinkedPortalDoor ==
 
=== CLinkedPortalDoor ===
{{todo}}
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 337: Line 471:
|}
|}


== CPlayerVoiceListener ==
 
=== CPlayerVoiceListener ===
{{todo}}
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 352: Line 491:
|}
|}


== CPortal_Player ==
 
=== CPortal_Player ===
{{todo}}
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 375: Line 519:
|}
|}


== CPropLinkedPortalDoor ==
 
=== CPropLinkedPortalDoor ===
{{todo}}
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 390: Line 539:
|}
|}


== CSceneEntity ==
 
=== CSceneEntity ===
Extends [[#CBaseEntity|CBaseEntity]]
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 425: Line 579:
|}
|}


== CScriptKeyValues ==
 
=== CScriptKeyValues ===
Script handle representation of a models [[$keyvalues]] block.
Sub keys are instances of the same class.
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 468: Line 628:
|}
|}


== CTriggerCamera ==
 
=== CTriggerCamera ===
Extends [[#CBaseEntity|CBaseEntity]]
 
 
==== Methods ====
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 482: Line 647:
| set camera's current fov in integer degrees and fov change rate as float
| set camera's current fov in integer degrees and fov change rate as float
|}
|}
=== Math ===
The built-in [http://www.squirrel-lang.org/mainsite/doc/sqstdlib2.html#d0e1519 Squirrel math library].
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>abs</code>
| <code> int abs(float ''x'')</code>
| Returns the absolute value of <code>x</code> as an integer.
|-
| <code>acos</code>
| <code> float acos(float ''x'')</code>
| Returns the arccosine of <code>x</code>.
|-
| <code>asin</code>
| <code> float asin(float ''x'')</code>
| Returns the arcsine of <code>x</code>.
|-
| <code>atan</code>
| <code> float atan(float ''x'')</code>
| Returns the arctangent of <code>x</code>.
|-
| <code>atan2</code>
| <code> float atan2(float ''x'', float ''y'')</code>
| Returns the arctangent of <code>x/y</code>.
|-
| <code>ceil</code>
| <code> float ceil(float ''x'')</code>
| Returns a float value representing the smallest integer that is greater than or equal to <code>x</code>.
|-
| <code>cos</code>
| <code> float cos(float ''x'')</code>
| Returns the cosine of <code>x</code>.
|-
| <code>exp</code>
| <code> float exp(float ''x'')</code>
| Returns the exponential value (<code>e^x</code>) of the float parameter <code>x</code>.
|-
| <code>fabs</code>
| <code> float fabs(float ''x'')</code>
| Returns the absolute value of <code>x</code> as a float.
|-
| <code>floor</code>
| <code> float floor(float ''x'')</code>
| Returns a float value representing the largest integer that is less than or equal to <code>x</code>.
|-
| <code>log</code>
| <code> float log(float ''x'')</code>
| Returns the natural logarithm of <code>x</code>.
|-
| <code>log10</code>
| <code> float log10(float ''x'')</code>
| Returns the logarithm base-10 of <code>x</code>.
|-
| <code>pow</code>
| <code> float pow(float ''x'', float ''y'')</code>
| Returns <code>x</code> raised to the power of <code>y</code>.
|-
| <code>rand</code>
| <code> int rand()</code>
| Returns a pseudorandom integer in the range 0 to <code>RAND_MAX</code>.
|-
| <code>sin</code>
| <code> float sin(float ''x'')</code>
| Returns the sine of <code>x</code>.
|-
| <code>sqrt</code>
| <code> float sqrt(float ''x'')</code>
| Returns the square root of <code>x</code>.
|-
| <code>srand</code>
| <code> void srand(float ''seed'')</code>
| Sets the starting point for generating a series of pseudorandom integers.
|-
| <code>tan</code>
| <code> float tan(float ''x'')</code>
| Returns the tangent of <code>x</code>.
|}
=== Vector ===
Represents an x/y/z position, returned/passed to many functions. It takes the 3 x/y/z positions as a parameter.<br>
A few math operations can be applied to vectors - ''+/-'' between any two vectors, and <code>Vector * number</code> in that order only. All three operations return another vector. Other math operations are done with method calls:
==== Methods ====
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>Cross</code>
| <code>Vector Vector::Cross(Vector other)</code>
| Return the vector cross product - <code>this × other</code>.
|-
| <code>Dot</code>
| <code>float Vector::Dot(Vector other)</code>
| Return the vector dot product - <code>this · other</code>.
|-
| <code>Length</code>
| <code>float Vector::Length()</code>
| Return the distance from the origin.
|-
| <code>Length2D</code>
| <code>float Vector::Length2D()</code>
| Return the distance from the origin, ignoring the Z axis.
|-
| <code>LengthSqr</code>
| <code>float Vector::LengthSqr()</code>
| Return the distance from the origin, but squared. This is faster to compute since a square root isn\'t required.
|-
| <code>Length2DSqr</code>
| <code>float Vector::Length2DSqr()</code>
| Return the distance from the origin, ignoring the Z axis and squared. This is faster to compute since a square root isn\'t required.
|-
| <code>Norm</code>
| <code>float Vector::Norm()</code>
| Modify the vector to have a length of 1, and return its original length.
|-
| <code>ToKVString</code>
| <code>string Vector::ToKVString()</code>
| Return a string in the form "X Y Z".
|}


== Other functions ==
== Other functions ==
Line 489: Line 783:
! Description
! Description
|-
|-
| <code>AddBranchLevelName</code>
| <code>Assert</code>
| <code>void AddBranchLevelName(int, string)</code>
| <code>void Assert(''exp'', string ''message'' = null)</code>
| Adds a level to the specified branche's list.
| Throws an exception if ''exp'' equates to false, optionally with message.
|-
| <code>AddCoopCreditsName</code>
| <code>void AddCoopCreditsName(string)</code>
| Adds a name to the coop credit's list.
|-
|-
| <code>CreateProp</code>
| <code>CreateProp</code>
| <code>handle CreateProp(string, Vector, string, int)</code>
| <code>handle CreateProp(string classname, Vector origin, string modelname, int activity)</code>
| Create a physics prop
| Create a prop. The class should be a prop_physics style entity.
|-
|-
| <code>CreateSceneEntity</code>
| <code>CreateSceneEntity</code>
Line 506: Line 796:
|-
|-
| <code>DebugDrawBox</code>
| <code>DebugDrawBox</code>
| <code>void DebugDrawBox(Vector, Vector, Vector, int, int, int, int, float)</code>
| <code>void DebugDrawBox(Vector origin, Vector mins, Vector maxs, int r, int g, int b, int alpha, float duration)</code>
| Draw a debug overlay box
| Draw a debug box, for visualizing code. It's positioned at <code>origin</code>, with the dimensions <code>mins</code>/<code>maxs</code> Developer must be on to show this, and it'll stay around for <code>duration</code> seconds (or 1 frame if -1.0). The color ranges from 0-255.
|-
|-
| <code>DebugDrawLine</code>
| <code>DebugDrawLine</code>
| <code>void DebugDrawLine(Vector, Vector, int, int, int, bool, float)</code>
| <code>void DebugDrawLine(Vector start, Vector end, int r, int g, int b, bool hitTest, float duration)</code>
| Draw a debug overlay box
| Draw a debug line, for visualizing code. Developer must be on to show this, and it'll stay around for <code>duration</code> seconds (or 1 frame if -1.0). The color ranges from 0-255.
|-
|-
| <code>DoIncludeScript</code>
| <code>DoIncludeScript</code>
| <code>bool DoIncludeScript(string, handle)</code>
| <code>bool DoIncludeScript(string ''filename'', table ''scope'')</code>
| Execute a script (internal)
| Execute the script file <code>"scripts/vscripts/" + filename</code> in the scope of <code>scope</code>. The extension <code>.nut</code> can be omitted.
|-
| <code>IncludeScript</code>
| <code>bool IncludeScript(string ''filename'', table ''scope'' = null)</code>
| Execute the script file <code>"scripts/vscripts/" + filename</code> in the scope of <code>scope</code>, <code>this</code> by default. The extension <code>.nut</code> can be omitted.
|-
| <code>DoEntFire</code>
| <code>void DoEntFire(string ''target'', string ''action'', string ''value'', float ''delay'', handle ''activator'', handle ''caller'')</code>
| Generate an entity [[I/O]] event.
|-
|-
| <code>EntFire</code>
| <code>EntFire</code>
| <code>function EntFire(target, action, value, delay, activator)</code>
| <code>function EntFire(target, action, value, delay, activator)</code>
| Generate and entity i/o event
| Generate an entity [[I/O]] event. Value, delay and activator are optional.
|-
|-
| <code>EntFireByHandle</code>
| <code>EntFireByHandle</code>
| <code>void EntFireByHandle(handle, string, string, float, handle, handle)</code>
| <code>void EntFireByHandle(handle target, string action, string value, float delay, handle activator, handle caller)</code>
| Generate and entity i/o event. First parameter is an entity instance.
| Generate an entity I/O event. First parameter is an entity instance.
|-
|-
| <code>FrameTime</code>
| <code>FrameTime</code>
| <code>float FrameTime()</code>
| <code>float FrameTime()</code>
| Get the time spent on the server in the last frame
| Get the time spent on the server in the last frame.
|-
| <code>GetBluePlayerIndex</code>
| <code>int GetBluePlayerIndex()</code>
| Player index of the blue player.
|-
| <code>GetCoopBranchLevelIndex</code>
| <code>int GetCoopBranchLevelIndex(int)</code>
| Given the 'branch' argument, returns the current chosen level.
|-
| <code>GetCoopSectionIndex</code>
| <code>int GetCoopSectionIndex()</code>
| Section that the coop players have selected to load.
|-
|-
| <code>GetDeveloperLevel</code>
| <code>GetDeveloperLevel</code>
| <code>int GetDeveloperLevel()</code>
| <code>int GetDeveloperLevel()</code>
| Gets the level of 'develoer'
| Gets the level of 'developer'.
|-
|-
| <code>GetHighestActiveBranch</code>
| <code>GetMapIndexInPlayOrder</code>
| <code>int GetHighestActiveBranch()</code>
| <code>int GetMapIndexInPlayOrder()</code>
| Returns which branches should be available in the hub.
| For workshop maps, determines which index (by order played) this map is. Returns -1 if entry is not found or -2 if this is not a workshop map.
|-
|-
| <code>GetMapName</code>
| <code>GetMapName</code>
Line 553: Line 839:
| Get the name of the map.
| Get the name of the map.
|-
|-
| <code>GetOrangePlayerIndex</code>
| <code>GetNumMapsPlayed</code>
| <code>int GetOrangePlayerIndex()</code>
| <code>int GetNumMapsPlayed()</code>
| Player index of the orange player.
| Returns how many workshop maps the player has played through.
|-
| <code>GetPlayer</code>
| <code>handle GetPlayer()</code>
| Returns the player (SP Only).
|-
|-
| <code>GetPlayerSilenceDuration</code>
| <code>GetPlayerSilenceDuration</code>
| <code>float GetPlayerSilenceDuration(int)</code>
| <code>float GetPlayerSilenceDuration(int player_index)</code>
| Time that the specified player has been silent on the mic.
| Time that the specified player has been silent on the mic.
|-
| <code>IsLevelComplete</code>
| <code>bool IsLevelComplete(int, int)</code>
| Returns true if the level in the specified branch is completed by either player.
|-
|-
| <code>IsMultiplayer</code>
| <code>IsMultiplayer</code>
| <code>bool IsMultiplayer()</code>
| <code>bool IsMultiplayer()</code>
| Is this a multiplayer game?
| Returns true if this is a multiplayer game, or false if singleplayer.
|-
| <code>IsPlayerLevelComplete</code>
| <code>bool IsPlayerLevelComplete(int, int, int)</code>
| Returns true if the level in the specified branch is completed by a specific player.
|-
|-
| <code>LoopSinglePlayerMaps</code>
| <code>LoopSinglePlayerMaps</code>
| <code>bool LoopSinglePlayerMaps()</code>
| <code>bool LoopSinglePlayerMaps()</code>
| Run the single player maps in a continuous loop.
| Returns true if the cvar <code>loopsingleplayermaps</code> is enabled. Still works in multiplayer.
|-
| <code>MarkMapComplete</code>
| <code>void MarkMapComplete(string)</code>
| Marks a maps a complete for both players.
|-
| <code>PrecacheMovie</code>
| <code>void PrecacheMovie(string)</code>
| Precaches a named movie. Only valid to call within the entity's 'Precache' function called on mapspawn.
|-
|-
| <code>RandomFloat</code>
| <code>RandomFloat</code>
| <code>float RandomFloat(float, float)</code>
| <code>float RandomFloat(float min, float max)</code>
| Generate a random floating point number within a range, inclusive
| Generate a random floating point number within a range, inclusive
|-
|-
| <code>RandomInt</code>
| <code>RandomInt</code>
| <code>int RandomInt(int, int)</code>
| <code>int RandomInt(int min, int max)</code>
| Generate a random integer within a range, inclusive
| Generate a random integer within a range, inclusive
|-
|-
| <code>RecordAchievementEvent</code>
| <code>RecordAchievementEvent</code>
| <code>void RecordAchievementEvent(string, int)</code>
| <code>void RecordAchievementEvent(string name, int player_index)</code>
| Records achievement event or progress
| Earns a given achievement or increases progress.
|-
|-
| <code>ScriptShowHudMessageAll</code>
| <code>RequestMapRating</code>
| <code>void ScriptShowHudMessageAll(string, float)</code>
| <code>void RequestMapRating()</code>
| Show center print text message.
| In workshop maps, pops up the map rating dialog for user input.
|-
|-
| <code>ScriptSteamShowURL</code>
| <code>RetrieveNativeSignature</code>
| <code>bool ScriptSteamShowURL(string)</code>
| <code>void RetrieveNativeSignature(string ''nativeFunction'')</code>
| Bring up the steam overlay and shows the specified URL.  (Full address with protocol type is required, e.g. http://www.steamgames.com/)
| {{todo}}
|-
|-
| <code>SendToConsole</code>
| <code>SendToConsole</code>
| <code>void SendToConsole(string)</code>
| <code>void SendToConsole(string command)</code>
| Send a string to the console as a command
| Send a string to the console as a command. The command is treated as coming from the host in multiplayer.
|-
|-
| <code>SetDucking</code>
| <code>SetDucking</code>
| <code>void SetDucking(string, string, float)</code>
| <code>void SetDucking(string, string, float)</code>
| Set the level of an audio ducking channel
| Set the level of an audio ducking channel.
|-
| <code>SetMapAsPlayed</code>
| <code>int SetMapAsPlayed()</code>
| For workshop maps, adds the current map to the play order and returns the new index therein. Returns -2 if this is not a workshop map.
|-
|-
| <code>ShowMessage</code>
| <code>ShowMessage</code>
| <code>void ShowMessage(string)</code>
| <code>void ShowMessage(string)</code>
| Print a hud message on all clients
| Print a HUD message on all clients.
|-
|-
| <code>Time</code>
| <code>Time</code>
Line 626: Line 896:
|-
|-
| <code>TraceLine</code>
| <code>TraceLine</code>
| <code>float TraceLine(Vector, Vector, handle)</code>
| <code>float TraceLine(Vector start, Vector end, handle ignored_ent)</code>
| given 2 points & ent to ignore, return fraction along line that hits world or models
| Given 2 points and an entity to ignore, returns fraction along line that hits the world. Does not hit entities, seemingly making the ignored entity parameter useless.
|-
|-
| <code>UniqueString</code>
| <code>UniqueString</code>
| <code>function UniqueString(string)</code>
| <code>string UniqueString(string ''suffix'' = "")</code>
| 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. Equivalent to <code>DoUniqueString(suffix)</code>.
|-
| <code>DoUniqueString</code>
| <code>string DoUniqueString(string ''suffix'')</code>
| 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.
| 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.
|-
| <code>__ReplaceClosures</code>
| <code>void __ReplaceClosures(function ''script'', table ''scope'')</code>
| Internal function called in <code>script_reload_</code> server commands.
|}
|}


== Introduced in "Peer Review" ==
=== Singleplayer only ===
These were introduced in Portal 2's first DLC, "Peer Review", as a measure against cheating.
 
These functions can only be used in singleplayer games, and may cause errors if used in multiplayer.
 
{| class="standard-table" style="width: 100%;"
{| class="standard-table" style="width: 100%;"
! Function
! Function
Line 641: Line 921:
! Description
! Description
|-
|-
| <code>TryDLC1InstalledOrCatch</code>
| <code>GetPlayer</code>
| <code>void TryDLC1InstalledOrCatch()</code>
| <code>handle GetPlayer()</code>
| Throws an exception if "Peer Review" isn't installed.
| Returns the player.
|-
|-
| <code>GivePlayerPortalgun</code>
| <code>GivePlayerPortalgun</code>
| <code>void GivePlayerPortalgun()</code>
| <code>void GivePlayerPortalgun()</code>
| Equips the player with a blue-only portalgun.
| Equips the player with a blue-only portalgun.
|-
| <code>PrecacheMovie</code>
| <code>void PrecacheMovie(string)</code>
| Precaches a named movie. Only valid to call within the entity's 'Precache' function called on mapspawn.
|-
| <code>ScriptShowHudMessageAll</code>
| <code>void ScriptShowHudMessageAll(string, float)</code>
| Show center print text message for specified number of seconds.
|-
| <code>ScriptSteamShowURL</code>
| <code>bool ScriptSteamShowURL(string)</code>
| Bring up the steam overlay and shows the specified URL.  (Full address with protocol type is required, e.g. http://www.steamgames.com/)
|-
| <code>TryDLC1InstalledOrCatch</code>
| <code>void TryDLC1InstalledOrCatch()</code>
| Throws an exception if the Peer Review DLC isn't installed. Useless in the current PC version of the game, as Peer Review will always be present.
|-
|-
| <code>UpgradePlayerPortalgun</code>
| <code>UpgradePlayerPortalgun</code>
Line 656: Line 952:
| <code>void UpgradePlayerPotatogun()</code>
| <code>void UpgradePlayerPotatogun()</code>
| Upgrades the player's portalgun to shoot orange portals and have PotatOS impaled on it.
| Upgrades the player's portalgun to shoot orange portals and have PotatOS impaled on it.
|}
=== Multiplayer only ===
These functions can only be used in multiplayer games, and may cause errors if used in singleplayer.
{| class="standard-table" style="width: 100%;"
! Function
! Signature
! Description
|-
| <code>AddBranchLevelName</code>
| <code>void AddBranchLevelName(int, string)</code>
| Adds a level to the specified branch's list. {{note|In co-op maps, this function must be called at least once or players will not be able to move.}}
|-
| <code>AddCoopCreditsName</code>
| <code>void AddCoopCreditsName(string)</code>
| Adds a name to the coop credit's list.
|-
| <code>AddGladosSpokenFlags</code>
| <code>void AddGladosSpokenFlags(int, int)</code>
| Adds bit flags for specific lines that are tracked per session.
|-
| <code>CoopGladosBlowUpBots</code>
| <code>void CoopGladosBlowUpBots()</code>
| Blows up both robots and prevents respawning.
|-
| <code>CoopGetNumPortalsPlaced</code>
| <code>int CoopGetNumPortalsPlaced()</code>
| Returns the number of portals the players have placed so far.
|-
| <code>CoopGetLevelsCompletedThisBranch</code>
| <code>int CoopGetLevelsCompletedThisBranch()</code>
| Returns the number of levels the players have completed in their run of the current branch.
|-
| <code>CoopGetBranchTotalLevelCount</code>
| <code>int CoopGetBranchTotalLevelCount()</code>
| Returns the number of levels in the current branch.
|-
| <code>CoopSetCameFromLastDLCMap</code>
| <code>void CoopSetCameFromLastDLCMap(bool)</code>
| Set whether the players came from the last coop DLC map or not.
|-
| <code>CoopSetMapRunTime</code>
| <code>void CoopSetMapRunTime(float runLength)</code>
| Sets the time to complete a coop map from spawn to completing the puzzle. (Possibly related to the Triple Crown achievement.)
|-
| <code>GetBluePlayerIndex</code>
| <code>int GetBluePlayerIndex()</code>
| Player index of the blue player.
|-
| <code>GetCameFromLastDLCMap</code>
| <code>bool GetCameFromLastDLCMap()</code>
| Returns true if coming from the last DLC coop map (as set by <code>CoopSetCameFromLastDLCMap</code>).
|-
| <code>GetCoopBranchLevelIndex</code>
| <code>int GetCoopBranchLevelIndex(int)</code>
| Given the 'branch' argument, returns the current chosen level.
|-
| <code>GetCoopSectionIndex</code>
| <code>int GetCoopSectionIndex()</code>
| Section that the coop players have selected to load.
|-
| <code>GetGladosSpokenFlags</code>
| <code>int GetGladosSpokenFlags(int)</code>
| Returns bit flags for specific lines that are tracked per session.
|-
| <code>GetHaveSeenDLCTubesReveal</code>
| <code>bool GetHaveSeenDLCTubesReveal()</code>
| Get whether players have seen the DLC tubes reveal this session (as set by <code>SetHaveSeenDLCTubesReveal</code>).
|-
| <code>GetHighestActiveBranch</code>
| <code>int GetHighestActiveBranch()</code>
| Returns which branches should be available in the hub.
|-
| <code>GetNumPlayersConnected</code>
| <code>int GetNumPlayersConnected()</code>
| Returns how many players are connected. In normal co-op, this will almost always be 2.
|-
| <code>GetOrangePlayerIndex</code>
| <code>int GetOrangePlayerIndex()</code>
| Player index of the orange player.
|-
| <code>GetPlayerDeathCount</code>
| <code>int GetPlayerDeathCount(int player)</code>
| Returns the number of times that a specific player has died in the session.
|-
| <code>IsBranchComplete</code>
| <code>bool IsBranchComplete(int course)</code>
| Returns true if every level in the course has been completed by either player.
|-
| <code>IsLevelComplete</code>
| <code>bool IsLevelComplete(int course, int level)</code>
| Returns true if the level in the specified course is completed by either player.
|-
| <code>IsLocalSplitScreen</code>
| <code>bool IsLocalSplitScreen()</code>
| Returns true if players are in split screen.
|-
| <code>IsPlayerBranchComplete</code>
| <code>bool IsPlayerBranchComplete(int player, int course)</code>
| Returns true if every level in the course has been completed by the specified player.
|-
| <code>IsPlayerLevelComplete</code>
| <code>bool IsPlayerLevelComplete(int, int, int)</code>
| Returns true if the level in the specified course is completed by a specific player.
|-
| <code>MarkMapComplete</code>
| <code>void MarkMapComplete(string)</code>
| Marks a maps a complete for both players.
|-
| <code>NotifySpeedRunSuccess</code>
| <code>void NotifySpeedRunSuccess(int runLength, string mapname)</code>
| Tells the client that a successful speed run has been completed. (Used for the Triple Crown achievement.)
|-
| <code>SaveMPStatsData</code>
| <code>void SaveMPStatsData()</code>
| Save the multiplayer stats for the score board.
|-
| <code>SetHaveSeenDLCTubesReveal</code>
| <code>void SetHaveSeenDLCTubesReveal()</code>
| Set that players have seen the DLC tubes reveal this session.
|}
|}


== See also ==
== See also ==
* {{l4d2}} [[List of L4D2 Script Functions]]
* [[VScript]]
* [[VScript Fundamentals]]
* {{sq}} [[Squirrel]]
* [[PCapture-Lib - Portal 2 Script Library]]
* {{l4d2}} [[Left 4 Dead 2/Script Functions]]
* {{csgo}} [[List of Counter-Strike: Global Offensive Script Functions]]


[[Category:Portal 2]]
[[Category:Portal 2]]
[[Category:Scripting]]
[[Category:Scripting]]

Latest revision as of 15:27, 14 July 2025

English (en)中文 (zh)Translate (Translate)


This list contains all engine-related Squirrel functions available for VScript in Portal 2 Portal 2. It can be printed in-game with the script_help command while running in tools mode.

Variables

Instance Type Description
Entities CEntities Provides access to spawned entities in the server.


Constants

Instance Type Value
_charsize_ integer 1
_floatsize_ integer 4
_intsize_ integer 4
_version_ string "Squirrel 2.2.3 stable"
RAND_MAX integer 32767
PI float 3.14159


Classes

CBaseEntity

This is a script handle class for entities. All entities spawned have a script handle using this or one of its subclasses.

All script handles in-game are accessible from Entities. Entity scripts can use self to access their own script handle. activator and caller variables can be accessed on function calls.


Methods

Function Signature Description
__KeyValueFromInt void __KeyValueFromInt(string key, int value) Sets an entity Keyvalue from an integer. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
__KeyValueFromFloat void __KeyValueFromFloat(string key, float value) Sets an entity Keyvalue from a float. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
__KeyValueFromString void __KeyValueFromString(string key, string value) Sets an entity Keyvalue from a string. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
__KeyValueFromVector void __KeyValueFromVector(string key, Vector value) Sets an entity Keyvalue from a Vector. This simply changes the value without executing any code that may be needed for the entity to process the KeyValue, so there may be unintended side effects.
ConnectOutput void CBaseEntity::ConnectOutput(string output, string func_name) Adds an I/O connection that will call the named function when the specified output fires.
Destroy void CBaseEntity::Destroy() Kill this entity.
DisconnectOutput void CBaseEntity::DisconnectOutput(string output, string func_name) Removes a connected script function from an I/O event.
EmitSound void CBaseEntity::EmitSound(string sound) Plays a sound from this entity.
EyePosition Vector CBaseEntity::EyePosition() Get vector to eye position - absolute coords.
FirstMoveChild handle CBaseEntity::FirstMoveChild() If in hierarchy, get the first move child.
GetAngles Vector CBaseEntity::GetAngles() Get entity pitch, yaw, roll as a vector.
GetAngularVelocity Vector CBaseEntity::GetAngularVelocity() Get the local angular velocity - returns a vector of pitch,yaw,roll.
GetBoundingMaxs Vector CBaseEntity::GetBoundingMaxs() Get a vector containing max bounds, centered on object.
GetBoundingMins Vector CBaseEntity::GetBoundingMins() Get a vector containing min bounds, centered on object.
GetCenter Vector CBaseEntity::GetCenter() Get vector to center of object - absolute coords.
GetClassname string CBaseEntity::GetClassname() Get the classname of this entity.
GetForwardVector Vector CBaseEntity::GetForwardVector() Get the forward vector (+X) of the entity.
GetHealth int CBaseEntity::GetHealth() Returns the current health.
GetLeftVector Vector CBaseEntity::GetLeftVector() Get the left vector of the entity.
GetMaxHealth int CBaseEntity::GetMaxHealth() Returns the maximum health.
GetModelKeyValues handle CBaseEntity::GetModelKeyValues() Get a KeyValue class instance on this entity's model.
GetModelName string CBaseEntity::GetModelName() Returns the name of the model.
GetMoveParent handle CBaseEntity::GetMoveParent() If in hierarchy, retrieves the entity's parent.
GetName string CBaseEntity::GetName() Get the Targetname of this entity.
GetOrigin Vector CBaseEntity::GetOrigin() Returns this entity's local origin.
GetOwner handle CBaseEntity::GetOwner() Gets this entity's owner.
GetPreTemplateName string CBaseEntity::GetPreTemplateName() Get the entity name stripped of template unique decoration - the &001 suffix.
GetRootMoveParent handle CBaseEntity::GetRootMoveParent() If in hierarchy, walks up the hierarchy to find the root parent
GetScriptId string CBaseEntity::GetScriptId() Retrieve the unique identifier used to refer to the entity within the scripting system.
GetScriptScope handle CBaseEntity::GetScriptScope() Retrieve the script-side data associated with an entity.
GetSoundDuration float CBaseEntity::GetSoundDuration(string, string) Returns float duration of the sound. Takes soundname and optional actormodelname.
GetTeam int CBaseEntity::GetTeam() Get the team this entity is on.
GetUpVector Vector CBaseEntity::GetUpVector() Get the up vector (+Z) of the entity.
GetVelocity Vector CBaseEntity::GetVelocity() Get the velocity of the entity. Note that this reads the QPhysics velocity value, so it only works for players, NPCs and moving brush entities. VPhysics objects always have a velocity of zero. A workaround is to record the position over multiple frames, and derive the velocity manually.
IsValid bool CBaseEntity::IsValid() Returns true if this entity is valid.
NextMovePeer handle CBaseEntity::NextMovePeer() Return the next entity in the same movement hierarchy.
PrecacheSoundScript void CBaseEntity::PrecacheSoundScript(string) Precache a sound for later playing. Should be called in the 'Precache()' hook function.
SetAbsOrigin void CBaseEntity::SetAbsOrigin(Vector) Teleport the entity to this world position.
SetAngles void CBaseEntity::SetAngles(float, float, float) Set entity pitch, yaw, roll
SetAngularVelocity void CBaseEntity::SetAngularVelocity(float, float, float) Set the local angular velocity - takes float pitch,yaw,roll velocities
SetForwardVector void CBaseEntity::SetForwardVector(Vector) Set the orientation of the entity to have this forward (+X) vector.
SetHealth void CBaseEntity::SetHealth(int) Sets the current health.
SetMaxHealth void CBaseEntity::SetMaxHealth(int) Sets the maximum health.
SetModel void CBaseEntity::SetModel(string) Change the model used for the entity. This can be used to change models for prop_weighted_cube or other similar entities. The model must be precached, which is usually done by placing it elsewhere in the map.
SetOrigin void CBaseEntity::SetOrigin(Vector) Teleport this entity to the given location.
SetOwner void CBaseEntity::SetOwner(handle) Sets this entity's owner.
SetSize void CBaseEntity::SetSize(Vector, Vector) Sets the bounding box size.
SetTeam void CBaseEntity::SetTeam(int) Set the team this entity is on.
SetVelocity void CBaseEntity::SetVelocity(Vector) Set local velocity. Note that this sets the QPhysics velocity value, so it only works for players, NPCs and moving brush entities. On VPhysics objects, this has no effect.
ValidateScriptScope bool CBaseEntity::ValidateScriptScope() Ensure that an entity's script scope has been created. This should be called before assigning to the entity's scope.
entindex int CBaseEntity::entindex() Returns the entity index.

CBaseAnimating

Extends CBaseEntity

Script handle class for animating entities such as props.


Methods

Function Signature Description
GetAttachmentAngles Vector CBaseAnimating::GetAttachmentAngles(int id) Get the attachment id's angles as a p,y,r vector.
GetAttachmentOrigin Vector CBaseAnimating::GetAttachmentOrigin(int id) Get the attachment id's origin vector
GetObjectScaleLevel int CBaseAnimating::GetObjectScaleLevel() The scale size of the entity
IsSequenceFinished bool CBaseAnimating::IsSequenceFinished() Ask whether the main sequence is done playing
LookupAttachment int CBaseAnimating::LookupAttachment(string) Get the ID for the named attachment.
SetBodygroup void CBaseAnimating::SetBodygroup(int group, int index) Sets a bodygroup. Group is the index for the desired group, and index is the desired part to use.


CBaseFlex

Extends CBaseAnimating


Methods

Function Signature Description
GetCurrentScene handle CBaseFlex::GetCurrentScene() Returns the instance of the oldest active scene entity (if any).
GetSceneByIndex handle CBaseFlex::GetSceneByIndex(int) Returns the instance of the scene entity at the specified index.


CBasePlayer

Extends CBaseAnimating


Methods

Function Signature Description
IsNoclipping bool CBasePlayer::IsNoclipping() Returns true if the player is in noclip mode.


CEntities

Script instance: Entities

An interface to find and iterate over the script handles for the entities in play.

To iterate over a set of entities, pass null to the previous argument in the appropriate method to start an iteration, or reference to a previously found entity to continue a search. Example:

//The first way
local ent = null;     //The variable name "ent" is arbitrary.
while(ent = Entities.FindByName(ent, "entityname"))     //Indeed, we mean '=' and not '==' ! The loop aborts if "ent" becomes null.
{
  //...     //In every iteration, "ent" is not null.
}

//The second way
for(local ent;ent = Entities.FindByName(ent, "entityname");)     //The variable name "ent" is arbitrary. Indeed, we mean '=' and not '==' ! The loop aborts if "ent" becomes null. (All the semicolons are correctly placed)
{
  //...     //In every iteration, "ent" is not null.
}


Methods

Function Signature Description
CreateByClassname handle CEntities::CreateByClassname(string) Creates an entity by classname
FindByClassname handle CEntities::FindByClassname(handle start_ent, string classname) Find entities by class name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
FindByClassnameNearest handle CEntities::FindByClassnameNearest(string classname, Vector loc, float radius) Find entities by class name nearest to a point.
FindByClassnameWithin handle CEntities::FindByClassnameWithin(handle start_ent, string classname, Vector loc, float radius) 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
FindByModel handle CEntities::FindByModel(handle start_ent, string model) Find entities by model name. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
FindByName handle CEntities::FindByName(handle start_ent, string targetname) Find entities by name (including wildcards). Pass 'null' to start an iteration, or reference to a previously found entity to continue a search.
FindByNameNearest handle CEntities::FindByNameNearest(string targetname, Vector loc, float radius) Find entities by name nearest to a point.
FindByNameWithin handle CEntities::FindByNameWithin(handle, string, Vector loc, float radius) Find entities by name within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
FindByTarget handle CEntities::FindByTarget(handle start_ent, string targetname) Find entities with a specific target keyvalue. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
FindInSphere handle CEntities::FindInSphere(handle start_ent, Vector loc, float radius) Find entities within a radius. Pass 'null' to start an iteration, or reference to a previously found entity to continue a search
First handle CEntities::First() Begin an iteration over the list of entities. Equivalent to Next(null).
Next handle CEntities::Next(handle) Continue an iteration over the list of entities, providing reference to a previously found entity.


CEnvEntityMaker

Extends CBaseEntity

Script handle class for env_entity_maker.


Methods

Function Signature Description
SpawnEntity void CEnvEntityMaker::SpawnEntity() Create an entity at the location of the maker
SpawnEntityAtEntityOrigin void CEnvEntityMaker::SpawnEntityAtEntityOrigin(handle) Create an entity at the location of a specified entity instance
SpawnEntityAtLocation void CEnvEntityMaker::SpawnEntityAtLocation(Vector, Vector) Create an entity at a specified location and orientaton, orientation is Euler angle in degrees (pitch, yaw, roll)
SpawnEntityAtNamedEntityOrigin void CEnvEntityMaker::SpawnEntityAtNamedEntityOrigin(string) Create an entity at the location of a named entity


CLinkedPortalDoor

[Todo]


Methods

Function Signature Description
GetPartnerInstance handle CLinkedPortalDoor::GetPartnerInstance() Get the instance handle of the door's linked partner
GetPartnername string CLinkedPortalDoor::GetPartnername() Returns the partnername of the door.


CPlayerVoiceListener

[Todo]


Methods

Function Signature Description
GetPlayerSpeechDuration float CPlayerVoiceListener::GetPlayerSpeechDuration(int) Returns the number of seconds the player has been continuously speaking.
IsPlayerSpeaking bool CPlayerVoiceListener::IsPlayerSpeaking(int) Returns whether the player specified is speaking.


CPortal_Player

[Todo]


Methods

Function Signature Description
GetWheatleyMonitorDestructionCount int CPortal_Player::GetWheatleyMonitorDestructionCount() Get number of wheatley monitors destroyed by the player.
IncWheatleyMonitorDestructionCount void CPortal_Player::IncWheatleyMonitorDestructionCount() Set number of wheatley monitors destroyed by the player.
TurnOffPotatos void CPortal_Player::TurnOffPotatos() Turns Off the Potatos material light
TurnOnPotatos void CPortal_Player::TurnOnPotatos() Turns On the Potatos material light


CPropLinkedPortalDoor

[Todo]


Methods

Function Signature Description
GetPartnerInstance handle CPropLinkedPortalDoor::GetPartnerInstance() Get the instance handle of the door's linked partner
GetPartnername string CPropLinkedPortalDoor::GetPartnername() Returns the partnername of the door.


CSceneEntity

Extends CBaseEntity


Methods

Function Signature Description
AddBroadcastTeamTarget void CSceneEntity::AddBroadcastTeamTarget(int) Adds a team (by index) to the broadcast list
EstimateLength float CSceneEntity::EstimateLength() Returns length of this scene in seconds.
FindNamedEntity handle CSceneEntity::FindNamedEntity(string) given an entity reference, such as !target, get actual entity from scene object
IsPaused bool CSceneEntity::IsPaused() If this scene is currently paused.
IsPlayingBack bool CSceneEntity::IsPlayingBack() If this scene is currently playing.
LoadSceneFromString bool CSceneEntity::LoadSceneFromString(string, string) given a dummy scene name and a vcd string, load the scene
RemoveBroadcastTeamTarget void CSceneEntity::RemoveBroadcastTeamTarget(int) Removes a team (by index) from the broadcast list


CScriptKeyValues

Script handle representation of a models $keyvalues block. Sub keys are instances of the same class.


Methods

Function Signature Description
FindKey handle CScriptKeyValues::FindKey(string) Given a KeyValues object and a key name, find a KeyValues object associated with the key name
GetFirstSubKey handle CScriptKeyValues::GetFirstSubKey() Given a KeyValues object, return the first sub key object
GetKeyBool bool CScriptKeyValues::GetKeyBool(string) Given a KeyValues object and a key name, return associated bool value
GetKeyFloat float CScriptKeyValues::GetKeyFloat(string) Given a KeyValues object and a key name, return associated float value
GetKeyInt int CScriptKeyValues::GetKeyInt(string) Given a KeyValues object and a key name, return associated integer value
GetKeyString string CScriptKeyValues::GetKeyString(string) Given a KeyValues object and a key name, return associated string value
GetNextKey handle CScriptKeyValues::GetNextKey() Given a KeyValues object, return the next key object in a sub key group
IsKeyEmpty bool CScriptKeyValues::IsKeyEmpty(string) Given a KeyValues object and a key name, return true if key name has no value
ReleaseKeyValues void CScriptKeyValues::ReleaseKeyValues() Given a root KeyValues object, release its contents


CTriggerCamera

Extends CBaseEntity


Methods

Function Signature Description
GetFov int CTriggerCamera::GetFov() get camera's current fov setting as integer
SetFov void CTriggerCamera::SetFov(int, float) set camera's current fov in integer degrees and fov change rate as float


Math

The built-in Squirrel math library.


Function Signature Description
abs int abs(float x) Returns the absolute value of x as an integer.
acos float acos(float x) Returns the arccosine of x.
asin float asin(float x) Returns the arcsine of x.
atan float atan(float x) Returns the arctangent of x.
atan2 float atan2(float x, float y) Returns the arctangent of x/y.
ceil float ceil(float x) Returns a float value representing the smallest integer that is greater than or equal to x.
cos float cos(float x) Returns the cosine of x.
exp float exp(float x) Returns the exponential value (e^x) of the float parameter x.
fabs float fabs(float x) Returns the absolute value of x as a float.
floor float floor(float x) Returns a float value representing the largest integer that is less than or equal to x.
log float log(float x) Returns the natural logarithm of x.
log10 float log10(float x) Returns the logarithm base-10 of x.
pow float pow(float x, float y) Returns x raised to the power of y.
rand int rand() Returns a pseudorandom integer in the range 0 to RAND_MAX.
sin float sin(float x) Returns the sine of x.
sqrt float sqrt(float x) Returns the square root of x.
srand void srand(float seed) Sets the starting point for generating a series of pseudorandom integers.
tan float tan(float x) Returns the tangent of x.


Vector

Represents an x/y/z position, returned/passed to many functions. It takes the 3 x/y/z positions as a parameter.
A few math operations can be applied to vectors - +/- between any two vectors, and Vector * number in that order only. All three operations return another vector. Other math operations are done with method calls:


Methods

Function Signature Description
Cross Vector Vector::Cross(Vector other) Return the vector cross product - this × other.
Dot float Vector::Dot(Vector other) Return the vector dot product - this · other.
Length float Vector::Length() Return the distance from the origin.
Length2D float Vector::Length2D() Return the distance from the origin, ignoring the Z axis.
LengthSqr float Vector::LengthSqr() Return the distance from the origin, but squared. This is faster to compute since a square root isn\'t required.
Length2DSqr float Vector::Length2DSqr() Return the distance from the origin, ignoring the Z axis and squared. This is faster to compute since a square root isn\'t required.
Norm float Vector::Norm() Modify the vector to have a length of 1, and return its original length.
ToKVString string Vector::ToKVString() Return a string in the form "X Y Z".


Other functions

Function Signature Description
Assert void Assert(exp, string message = null) Throws an exception if exp equates to false, optionally with message.
CreateProp handle CreateProp(string classname, Vector origin, string modelname, int activity) Create a prop. The class should be a prop_physics style entity.
CreateSceneEntity handle CreateSceneEntity(string) Create a scene entity to play the specified scene.
DebugDrawBox void DebugDrawBox(Vector origin, Vector mins, Vector maxs, int r, int g, int b, int alpha, float duration) Draw a debug box, for visualizing code. It's positioned at origin, with the dimensions mins/maxs Developer must be on to show this, and it'll stay around for duration seconds (or 1 frame if -1.0). The color ranges from 0-255.
DebugDrawLine void DebugDrawLine(Vector start, Vector end, int r, int g, int b, bool hitTest, float duration) Draw a debug line, for visualizing code. Developer must be on to show this, and it'll stay around for duration seconds (or 1 frame if -1.0). The color ranges from 0-255.
DoIncludeScript bool DoIncludeScript(string filename, table scope) Execute the script file "scripts/vscripts/" + filename in the scope of scope. The extension .nut can be omitted.
IncludeScript bool IncludeScript(string filename, table scope = null) Execute the script file "scripts/vscripts/" + filename in the scope of scope, this by default. The extension .nut can be omitted.
DoEntFire void DoEntFire(string target, string action, string value, float delay, handle activator, handle caller) Generate an entity I/O event.
EntFire function EntFire(target, action, value, delay, activator) Generate an entity I/O event. Value, delay and activator are optional.
EntFireByHandle void EntFireByHandle(handle target, string action, string value, float delay, handle activator, handle caller) Generate an entity I/O event. First parameter is an entity instance.
FrameTime float FrameTime() Get the time spent on the server in the last frame.
GetDeveloperLevel int GetDeveloperLevel() Gets the level of 'developer'.
GetMapIndexInPlayOrder int GetMapIndexInPlayOrder() For workshop maps, determines which index (by order played) this map is. Returns -1 if entry is not found or -2 if this is not a workshop map.
GetMapName string GetMapName() Get the name of the map.
GetNumMapsPlayed int GetNumMapsPlayed() Returns how many workshop maps the player has played through.
GetPlayerSilenceDuration float GetPlayerSilenceDuration(int player_index) Time that the specified player has been silent on the mic.
IsMultiplayer bool IsMultiplayer() Returns true if this is a multiplayer game, or false if singleplayer.
LoopSinglePlayerMaps bool LoopSinglePlayerMaps() Returns true if the cvar loopsingleplayermaps is enabled. Still works in multiplayer.
RandomFloat float RandomFloat(float min, float max) Generate a random floating point number within a range, inclusive
RandomInt int RandomInt(int min, int max) Generate a random integer within a range, inclusive
RecordAchievementEvent void RecordAchievementEvent(string name, int player_index) Earns a given achievement or increases progress.
RequestMapRating void RequestMapRating() In workshop maps, pops up the map rating dialog for user input.
RetrieveNativeSignature void RetrieveNativeSignature(string nativeFunction) [Todo]
SendToConsole void SendToConsole(string command) Send a string to the console as a command. The command is treated as coming from the host in multiplayer.
SetDucking void SetDucking(string, string, float) Set the level of an audio ducking channel.
SetMapAsPlayed int SetMapAsPlayed() For workshop maps, adds the current map to the play order and returns the new index therein. Returns -2 if this is not a workshop map.
ShowMessage void ShowMessage(string) Print a HUD message on all clients.
Time float Time() Get the current server time
TraceLine float TraceLine(Vector start, Vector end, handle ignored_ent) Given 2 points and an entity to ignore, returns fraction along line that hits the world. Does not hit entities, seemingly making the ignored entity parameter useless.
UniqueString string UniqueString(string suffix = "") 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. Equivalent to DoUniqueString(suffix).
DoUniqueString string DoUniqueString(string suffix) 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.
__ReplaceClosures void __ReplaceClosures(function script, table scope) Internal function called in script_reload_ server commands.

Singleplayer only

These functions can only be used in singleplayer games, and may cause errors if used in multiplayer.

Function Signature Description
GetPlayer handle GetPlayer() Returns the player.
GivePlayerPortalgun void GivePlayerPortalgun() Equips the player with a blue-only portalgun.
PrecacheMovie void PrecacheMovie(string) Precaches a named movie. Only valid to call within the entity's 'Precache' function called on mapspawn.
ScriptShowHudMessageAll void ScriptShowHudMessageAll(string, float) Show center print text message for specified number of seconds.
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/)
TryDLC1InstalledOrCatch void TryDLC1InstalledOrCatch() Throws an exception if the Peer Review DLC isn't installed. Useless in the current PC version of the game, as Peer Review will always be present.
UpgradePlayerPortalgun void UpgradePlayerPortalgun() Upgrades the player's portalgun to shoot orange portals.
UpgradePlayerPotatogun void UpgradePlayerPotatogun() Upgrades the player's portalgun to shoot orange portals and have PotatOS impaled on it.

Multiplayer only

These functions can only be used in multiplayer games, and may cause errors if used in singleplayer.

Function Signature Description
AddBranchLevelName void AddBranchLevelName(int, string) Adds a level to the specified branch's list.
Note.pngNote:In co-op maps, this function must be called at least once or players will not be able to move.
AddCoopCreditsName void AddCoopCreditsName(string) Adds a name to the coop credit's list.
AddGladosSpokenFlags void AddGladosSpokenFlags(int, int) Adds bit flags for specific lines that are tracked per session.
CoopGladosBlowUpBots void CoopGladosBlowUpBots() Blows up both robots and prevents respawning.
CoopGetNumPortalsPlaced int CoopGetNumPortalsPlaced() Returns the number of portals the players have placed so far.
CoopGetLevelsCompletedThisBranch int CoopGetLevelsCompletedThisBranch() Returns the number of levels the players have completed in their run of the current branch.
CoopGetBranchTotalLevelCount int CoopGetBranchTotalLevelCount() Returns the number of levels in the current branch.
CoopSetCameFromLastDLCMap void CoopSetCameFromLastDLCMap(bool) Set whether the players came from the last coop DLC map or not.
CoopSetMapRunTime void CoopSetMapRunTime(float runLength) Sets the time to complete a coop map from spawn to completing the puzzle. (Possibly related to the Triple Crown achievement.)
GetBluePlayerIndex int GetBluePlayerIndex() Player index of the blue player.
GetCameFromLastDLCMap bool GetCameFromLastDLCMap() Returns true if coming from the last DLC coop map (as set by CoopSetCameFromLastDLCMap).
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.
GetGladosSpokenFlags int GetGladosSpokenFlags(int) Returns bit flags for specific lines that are tracked per session.
GetHaveSeenDLCTubesReveal bool GetHaveSeenDLCTubesReveal() Get whether players have seen the DLC tubes reveal this session (as set by SetHaveSeenDLCTubesReveal).
GetHighestActiveBranch int GetHighestActiveBranch() Returns which branches should be available in the hub.
GetNumPlayersConnected int GetNumPlayersConnected() Returns how many players are connected. In normal co-op, this will almost always be 2.
GetOrangePlayerIndex int GetOrangePlayerIndex() Player index of the orange player.
GetPlayerDeathCount int GetPlayerDeathCount(int player) Returns the number of times that a specific player has died in the session.
IsBranchComplete bool IsBranchComplete(int course) Returns true if every level in the course has been completed by either player.
IsLevelComplete bool IsLevelComplete(int course, int level) Returns true if the level in the specified course is completed by either player.
IsLocalSplitScreen bool IsLocalSplitScreen() Returns true if players are in split screen.
IsPlayerBranchComplete bool IsPlayerBranchComplete(int player, int course) Returns true if every level in the course has been completed by the specified player.
IsPlayerLevelComplete bool IsPlayerLevelComplete(int, int, int) Returns true if the level in the specified course is completed by a specific player.
MarkMapComplete void MarkMapComplete(string) Marks a maps a complete for both players.
NotifySpeedRunSuccess void NotifySpeedRunSuccess(int runLength, string mapname) Tells the client that a successful speed run has been completed. (Used for the Triple Crown achievement.)
SaveMPStatsData void SaveMPStatsData() Save the multiplayer stats for the score board.
SetHaveSeenDLCTubesReveal void SetHaveSeenDLCTubesReveal() Set that players have seen the DLC tubes reveal this session.

See also