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

From Valve Developer Community
< Ru
Jump to: navigation, search
English (en)Русский (ru)Translate (Translate)


Info content.png
This page needs to be translated.
This page either contains information that is only partially or incorrectly translated, or there isn't a translation yet.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article tries to comply with the alternate languages guide.

Squirrel Это список всех Squirrel-функций движка, доступных для VScript(en) в Portal 2 Portal 2. Его можно вызвать в игре, введя команду scipt_help в режиме режиме инструментов движка(en).

CBaseAnimating

Функция Ключ Описание
GetAttachmentAngles Vector CBaseAnimating::GetAttachmentAngles(int) Get the attachement id's angles as a p,y,r vector
GetAttachmentOrigin Vector CBaseAnimating::GetAttachmentOrigin(int) Get the attachement 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 named attachement id
SetBodygroup void CBaseAnimating::SetBodygroup(int, int) Sets a bodygroup


CBaseEntity

Function Signature Description
ConnectOutput void CBaseEntity::ConnectOutput(string, string) Adds an I/O connection that will call the named function when the specified output fires
Destroy void CBaseEntity::Destroy()
DisconnectOutput void CBaseEntity::DisconnectOutput(string, string) Removes a connected script function from an I/O event.
EmitSound void CBaseEntity::EmitSound(string) Plays a sound from this entity.
EyePosition Vector CBaseEntity::EyePosition() Get vector to eye position - absolute coords
FirstMoveChild handle CBaseEntity::FirstMoveChild()
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()
GetForwardVector Vector CBaseEntity::GetForwardVector() Get the forward vector of the entity
GetHealth int CBaseEntity::GetHealth()
GetLeftVector Vector CBaseEntity::GetLeftVector() Get the left vector of the entity
GetMaxHealth int CBaseEntity::GetMaxHealth()
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()
GetOrigin Vector CBaseEntity::GetOrigin()
GetOwner handle CBaseEntity::GetOwner() Gets this entity's owner
GetPreTemplateName string CBaseEntity::GetPreTemplateName() Get the entity name stripped of template unique decoration
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()
GetUpVector Vector CBaseEntity::GetUpVector() Get the up vector of the entity
GetVelocity Vector CBaseEntity::GetVelocity()
IsValid bool CBaseEntity::IsValid() Returns true if entity is valid
NextMovePeer handle CBaseEntity::NextMovePeer()
PrecacheSoundScript void CBaseEntity::PrecacheSoundScript(string) Precache a sound for later playing.
SetAbsOrigin void CBaseEntity::SetAbsOrigin(Vector) SetAbsOrigin
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 vector
SetHealth void CBaseEntity::SetHealth(int)
SetMaxHealth void CBaseEntity::SetMaxHealth(int)
SetModel void CBaseEntity::SetModel(string)
SetOrigin void CBaseEntity::SetOrigin(Vector)
SetOwner void CBaseEntity::SetOwner(handle) Sets this entity's owner
SetSize void CBaseEntity::SetSize(Vector, Vector)
SetTeam void CBaseEntity::SetTeam(int)
SetVelocity void CBaseEntity::SetVelocity(Vector)
ValidateScriptScope bool CBaseEntity::ValidateScriptScope() Ensure that an entity's script scope has been created
entindex int CBaseEntity::entindex()

CBaseFlex

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

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

CEntities

Function Signature Description
CreateByClassname handle CEntities::CreateByClassname(string) Creates an entity by classname
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
FindByClassnameNearest handle CEntities::FindByClassnameNearest(string, Vector, float) Find entities by class name nearest to a point.
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
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
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
FindByNameNearest handle CEntities::FindByNameNearest(string, Vector, float) Find entities by name nearest to a point.
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
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
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
First handle CEntities::First() Begin an iteration over the list of entities
Next handle CEntities::Next(handle) Continue an iteration over the list of entities, providing reference to a previously found entity

CEnvEntityMaker

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

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

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

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

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

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

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

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

Other functions

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.
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.
GetMapName string GetMapName() Get the name of the map.
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.
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
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
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
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.

Introduced in "Peer Review"

These were introduced in Portal 2's first DLC, "Peer Review", as a measure against cheating.

Функция Ключ Описание
TryDLC1InstalledOrCatch void TryDLC1InstalledOrCatch() Throws an exception if "Peer Review" isn't installed.
GivePlayerPortalgun void GivePlayerPortalgun() Equips the player with a blue-only portalgun.
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.

См. также