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

PCapture-Lib - Portal 2 VScript Library

From Valve Developer Community
Jump to: navigation, search
English (en)Translate (Translate)


PCapture-Lib is a comprehensive VScripts library for Portal 2 designed to enhance the capabilities of VScripters and facilitate the creation of engaging gameplay experiences.

This page provides a comprehensive overview of the classes and functions available in PCapture-Lib.

About

PCapture-Lib originated from the Project Capture modification for Portal 2 and is actively maintained by laVashik, an experienced Portal 2 modder known for their work on projects like Nullpoint Crisis, MultiPortals, Fanctronic. It provides a wide range of tools and utilities to address complex scripting challenges while maintaining an intuitive interface, empowering VScripters of all skill levels to realize more ambitious and immersive maps.

GitHub Repo: PCapture-LIB

The library is compatible with the following Source Engine games that support VScripts: Portal 2, Portal 2: Community Edition

If you find bugs or problems - create an Issue

Constants

Constant Type Description
COLLISION_GROUP_NONE integer Collides with nothing (0).
COLLISION_GROUP_DEBRIS integer Small, non-gameplay-interfering objects (1).
COLLISION_GROUP_DEBRIS_TRIGGER integer Like `DEBRIS`, but ignores `PUSHAWAY` (2).
COLLISION_GROUP_INTERACTIVE_DEBRIS integer Like `DEBRIS`, but doesn't collide with the same group (3).
COLLISION_GROUP_INTERACTIVE integer Interactive entities, ignores debris (4).
COLLISION_GROUP_PLAYER integer Used by players, ignores `PASSABLE_DOOR` (5).
COLLISION_GROUP_BREAKABLE_GLASS integer Breakable glass, ignores the same group and NPC line-of-sight (6).
COLLISION_GROUP_VEHICLE integer Driveable vehicles, always collides with `VEHICLE_CLIP` (7).
COLLISION_GROUP_PLAYER_MOVEMENT integer Player movement collision (8).
COLLISION_GROUP_NPC integer Used by NPCs, always collides with `DOOR_BLOCKER` (9).
COLLISION_GROUP_IN_VEHICLE integer Entities inside vehicles, no collisions (10).
COLLISION_GROUP_WEAPON integer Weapons, including dropped ones (11).
COLLISION_GROUP_VEHICLE_CLIP integer Only collides with `VEHICLE` (12).
COLLISION_GROUP_PROJECTILE integer Projectiles, ignore other projectiles (13).
COLLISION_GROUP_DOOR_BLOCKER integer Blocks NPCs, may collide with some projectiles (14).
COLLISION_GROUP_PASSABLE_DOOR integer Passable doors, allows players through (15).
COLLISION_GROUP_DISSOLVING integer Dissolved entities, only collide with `NONE` (16).
COLLISION_GROUP_PUSHAWAY integer Pushes props away from the player (17).
COLLISION_GROUP_NPC_ACTOR integer NPCs potentially stuck in a player (18).
COLLISION_GROUP_NPC_SCRIPTED integer NPCs in scripted sequences with collisions disabled (19).
SOLID_NONE integer No collision at all (0).
SOLID_BSP integer Uses Quake Physics engine (1).
SOLID_VPHYSICS integer Uses an axis-aligned bounding box (AABB) for collision (2).
SOLID_OBB integer Uses an oriented bounding box (OBB) for collision (3).
SOLID_OBB_YAW integer Uses an OBB constrained to yaw rotation (4).
SOLID_CUSTOM integer Custom/test solid type (5).
SOLID_VPHYSICS integer Uses VPhysics engine for realistic physics (6).

Math

The `Math` module provides various mathematical functions and objects, including those for linear interpolation, quaternions, vectors, and matrices. It aims to extend the standard mathematical capabilities of VScripts and simplify common mathematical operations.

Functions

Function Signature Description
min(...) number math::min(...) Finds the minimum value among the given arguments.
max(...) number math::max(...) Finds the maximum value among the given arguments.
clamp(number, min, max) number math::clamp(number, min, max) Clamps a number within the specified range, ensuring that the returned value is between the minimum and maximum values (inclusive).
round(value, precision) number math::round(value, precision) Rounds a number to the specified precision.
Sign(x) number math::Sign(x) Returns the sign of a number as -1, 0, or 1.
copysign(value, sign) number math::copysign(value, sign) Copies the sign of one number to another.
RemapVal(val, A, B, C, D) number math::RemapVal(val, A, B, C, D) Remaps a value from one range to another.
vector.isEqually(vec1, vec2) bool math::vector::isEqually(vec1, vec2) Checks if two vectors are equal by comparing their rounded components.
vector.mul(vec1, vec2) Vector math::vector::mul(vec1, vec2) Performs element-wise multiplication of two vectors.
vector.rotate(vec, angle) Vector math::vector::rotate(vec, angle) Rotates a vector by a given angle represented as Euler angles (pitch, yaw, roll).
vector.unrotate(vec, angle) Vector math::vector::unrotate(vec, angle) Un-rotates a vector by a given angle represented as Euler angles.
vector.random(min, max) Vector math::vector::random(min, max) Generates a random vector within the specified range. The range can be defined either by two vectors or by two numbers.
vector.reflect(dir, normal) Vector math::vector::reflect(dir, normal) Reflects a direction vector off a surface with a given normal vector.
vector.clamp(vec, min, max) Vector math::vector::clamp(vec, min, max) Clamps the components of a vector within the specified range.
vector.resize(vec, newLength) Vector math::vector::resize(vec, newLength) Resizes a vector to a new length while maintaining its direction.
vector.round(vec, precision) Vector math::vector::round(vec, precision) Rounds the components of a vector to the specified precision.
vector.sign(vec) Vector math::vector::sign(vec) Returns a new vector where each component represents the sign of the corresponding component in the input vector.
vector.abs(vector) Vector math::vector::abs(vector) Calculates the absolute value of each component in a vector and returns a new vector with the absolute values.
lerp.number(start, end, t) number math::lerp::number(start, end, t) Performs linear interpolation between two numbers.
lerp.vector(start, end, t) Vector math::lerp::vector(start, end, t) Performs linear interpolation between two vectors.
lerp.color(start, end, t) string math::lerp::color(start, end, t) Performs linear interpolation between two colors.
lerp.sVector(start, end, t) Vector math::lerp::sVector(start, end, t) Performs spherical linear interpolation (slerp) between two vectors.
lerp.spline(f) number math::lerp::spline(f) Performs cubic spline interpolation.
lerp.SmoothStep(edge0, edge1, x) number math::lerp::SmoothStep(edge0, edge1, x) Performs smooth interpolation between two values using a smoothstep function.
lerp.FLerp(f1, f2, i1, i2, x) number math::lerp::FLerp(f1, f2, i1, i2, x) Performs linear interpolation between two values with custom interpolation parameters.
lerp.SmoothCurve(x) number math::lerp::SmoothCurve(x) Applies a smooth curve function to a value.
lerp.SmoothProgress(progress) number math::lerp::SmoothProgress(progress) Calculates smooth progress based on a progress value.

Quaternion

Represents a quaternion (a mathematical object used for rotations in 3D space).

Methods

Function Signature Description
Quaternion(x, y, z, w) Quaternion Quaternion(x, y, z, w) Creates a new quaternion with the specified components.
fromEuler(angles) Quaternion Quaternion::fromEuler(angles) Creates a quaternion from Euler angles (pitch, yaw, roll).
fromVector(vector) Quaternion Quaternion::fromVector(vector) Creates a quaternion from a vector, with the w component of the quaternion set to 0.
rotateVector(vector) Vector Quaternion::rotateVector(vector) Rotates a vector by the quaternion.
unrotateVector(vector) Vector Quaternion::unrotateVector(vector) Un-rotates a vector by the quaternion, reversing the rotation that would be applied by `rotateVector`.
slerp(targetQuaternion, t) Quaternion Quaternion::slerp(targetQuaternion, t) Performs spherical linear interpolation (slerp) between this quaternion and the target quaternion.
normalize() Quaternion Quaternion::normalize() Normalizes the quaternion, scaling its components so that its length (magnitude) is 1.
dot(other) number Quaternion::dot(other) Calculates the dot product of this quaternion and another quaternion.
length() number Quaternion::length() Calculates the length (magnitude) of the quaternion.
inverse() Quaternion Quaternion::inverse() Calculates the inverse of the quaternion.
fromAxisAngle(axis, angle) Quaternion Quaternion::fromAxisAngle(axis, angle) Creates a quaternion from an axis and an angle of rotation around that axis.
toAxisAngle() table Quaternion::toAxisAngle() Converts the quaternion to an axis and an angle of rotation around that axis.
toVector() Vector Quaternion::toVector() Converts the quaternion to a vector representing Euler angles (pitch, yaw, roll) in degrees.
isEqually(other) bool Quaternion::isEqually(other) Checks if this quaternion is equal to another quaternion based on their components and length.
cmp(other) number Quaternion::cmp(other) Compares this quaternion to another quaternion based on their magnitudes.


Matrix

Represents a 3x3 matrix.

Methods

Function Signature Description
Matrix(a, b, c, d, e, f, g, h, k) Matrix Matrix(a, b, c, d, e, f, g, h, k) Creates a new matrix with the specified components.
fromEuler(angles) Matrix Matrix::fromEuler(angles) Creates a rotation matrix from Euler angles (pitch, yaw, roll).
rotateVector(point) Vector Matrix::rotateVector(point) Rotates a point using the matrix.
unrotateVector(point) Vector Matrix::unrotateVector(point) Un-rotates a point using the matrix.
transpose() Matrix Matrix::transpose() Transposes the matrix, swapping its rows and columns.
inverse() Matrix Matrix::inverse() Calculates the inverse of the matrix.
determinant() number Matrix::determinant() Calculates the determinant of the matrix.
scale(factor) Matrix Matrix::scale(factor) Scales the matrix by a given factor.
rotateX(angle) Matrix Matrix::rotateX(angle) Rotates the matrix around the X axis by a given angle.
isEqually(other) bool Matrix::isEqually(other) Checks if this matrix is equal to another matrix.
cmp(other) number Matrix::cmp(other) Compares this matrix to another matrix.


IDT (Improved Data Types)

The `IDT` module provides enhanced versions of standard VScripts data structures, including arrays, lists, and trees, with additional methods and functionality to improve efficiency and flexibility.

Array

Enhanced version of the standard VScripts array.

Methods

Function Signature Description
arayLib(arrray) arayLib arayLib(arrray) Creates a new `arrayLib` object from an existing array.
new(...) arayLib arayLib::new(...) Creates a new `arrayLib` object from a variable number of arguments.
append(value) arayLib arayLib::append(value) Appends a value to the end of the array.
apply(func) arayLib arayLib::apply(func) Applies a function to each element of the array.
clear() arayLib arayLib::clear() Removes all elements from the array.
extend(other) arayLib arayLib::extend(other) Appends all elements from another array or `arrayLib` to the end of this array.
filter(func) arayLib arayLib::filter(func) Creates a new `arrayLib` containing only the elements that satisfy the predicate function.
contains(value) bool arayLib::contains(value) Checks if the array contains the specified value.
search(value or func) number arayLib::search(value or func) Searches for a value or a matching element in the array.
insert(index, value) any arayLib::insert(index, value) Inserts a value into the array at the specified index.
len() number arayLib::len() Returns the number of elements in the array.
map(func) arayLib arayLib::map(func) Creates a new `arrayLib` by applying a function to each element of this array.
pop() any arayLib::pop() Removes and returns the last element of the array.
push(value) void arayLib::push(value) Appends a value to the end of the array.
remove(index) void arayLib::remove(index) Removes the element at the specified index from the array.
resize(size, fill) void arayLib::resize(size, fill) Resizes the array to the specified size.
reverse() arayLib arayLib::reverse() Reverses the order of elements in the array in-place.
slice(start, end) arayLib arayLib::slice(start, end) Returns a new `arrayLib` containing a portion of the array.
sort(func) arayLib arayLib::sort(func) Sorts the elements of the array in-place.
top() any arayLib::top() Returns the last element of the array.
join(separator) string arayLib::join(separator) Joins the elements of the array into a string, separated by the specified separator.
get(index, default) any arayLib::get(index, default) Returns the element at the specified index.
totable(recreate) table arayLib::totable(recreate) Converts the array to a table.
tolist() List arayLib::tolist() Converts the array to a `List` object.

List

Represents a doubly linked list. [Todo]

Methods

Function Signature Description
List(...) List List(...) Creates a new `List` object with optional initial elements.
fromArray(array) List List::fromArray(array) Creates a new `List` object from an existing array.
len() number List::len() Gets the length of the list.
append(value) void List::append(value) Appends a value to the end of the list.
insert(index, value) void List::insert(index, value) Inserts a value at a specific index in the list.
get(index, defaultValue) any List::get(index, defaultValue) Gets the value at a specific index in the list.
remove(index) void List::remove(index) Removes the node at a specific index from the list.
pop() any List::pop() Removes the last element from the list and returns its value.
top() any List::top() Gets the value of the last element in the list.
reverse() void List::reverse() Reverses the order of the elements in the list in-place.
clear() void List::clear() Removes all elements from the list.
join(separator) string List::join(separator) Joins the elements of the list into a string.
apply(func) List List::apply(func) Applies a function to each element of the list.
extend(other) List List::extend(other) Extends the list by appending all elements from another iterable.
search(value or func) number List::search(value or func) Searches for a value or a matching element in the list.
map(func) List List::map(func) Creates a new list by applying a function to each element of this list.
toarray() arayLib List::toarray() Converts the list to an array.

AVLTree

Represents a self-balancing binary search tree (AVL tree). [Todo]

Methods

Function Signature Description
AVLTree(...) AVLTree AVLTree(...) Creates a new `AVLTree` object with optional initial elements.
fromArray(array) AVLTree AVLTree::fromArray(array) Creates a new `AVLTree` object from an existing array.
len() number AVLTree::len() Gets the number of nodes in the tree.
toArray() arayLib AVLTree::toArray() Converts the tree to an array.
tolist() List AVLTree::tolist() Converts the tree to a list using inorder traversal (ascending order).
insert(key) void AVLTree::insert(key) Inserts a new node with the given key into the tree.
search(value) treeNode AVLTree::search(value) Searches for a node with the given value in the tree and returns the node if found.
remove(value) void AVLTree::remove(value) Removes the node with the given value from the tree.
GetMin() any AVLTree::GetMin() Returns the minimum value in the tree.
GetMax() any AVLTree::GetMax() Returns the maximum value in the tree.
inorderTraversal() arayLib AVLTree::inorderTraversal() Performs an inorder traversal of the tree and returns an array of nodes in ascending order.
printTree() void AVLTree::printTree() Prints a visual representation of the tree structure to the console.

Improved Entity (PcapEntity)

Provides additional functionality for manipulating entity properties, setting outputs, managing user data, and retrieving information about the entity's bounding box and other attributes.

Methods

Function Signature Description
PcapEntity(entity) PcapEntity PcapEntity::PcapEntity(entity) Creates a new `PcapEntity` object from a `CBaseEntity` object.
SetAngles(x, y, z) void PcapEntity::SetAngles(x, y, z) Sets the angles (pitch, yaw, roll) of the entity.
SetAbsAngles(angles) void PcapEntity::SetAbsAngles(angles) Sets the absolute rotation angles of the entity using a Vector.
Destroy() void PcapEntity::Destroy() Destroys the entity.
Kill(fireDelay) void PcapEntity::Kill(fireDelay) Kills the entity.
Dissolve() void PcapEntity::Dissolve() Dissolves the entity using an `env_entity_dissolver` entity.
IsValid() bool PcapEntity::IsValid() Checks if the entity is valid.
IsPlayer() bool PcapEntity::IsPlayer() Checks if the entity is the player entity.
EyePosition() Vector PcapEntity::EyePosition() Gets the eye position of the player entity as a Vector.
EyeAngles() Vector PcapEntity::EyeAngles() Gets the eye angles of the player entity as a Vector.
EyeForwardVector() Vector PcapEntity::EyeForwardVector() Gets the forward vector from the player entity's eye position.
SetKeyValue(key, value) void PcapEntity::SetKeyValue(key, value) Sets a key-value pair for the entity.
addOutput(outputName, target, input, param, delay, fires) void PcapEntity::addOutput(outputName, target, input, param, delay, fires) Sets an output for the entity, connecting it to a target entity and input.
ConnectOutputEx(outputName, script, delay, fires) void PcapEntity::ConnectOutputEx(outputName, script, delay, fires) Connects an output to a script function or string with optional delay and trigger count.
EmitSoundEx(soundName, timeDelay, eventName) void PcapEntity::EmitSoundEx(soundName, timeDelay, eventName) Plays a sound with an optional delay and event name for scheduling.
SetName(name) void PcapEntity::SetName(name) Sets the targetname of the entity.
SetUniqueName(prefix) void PcapEntity::SetUniqueName(prefix) Sets a unique targetname for the entity.
SetParent(parentEnt, fireDelay) void PcapEntity::SetParent(parentEnt, fireDelay) Sets the parent entity for the entity, establishing a parent-child relationship.
GetParent() Entity PcapEntity::GetParent() Gets the parent entity of the entity, if set.
SetCollision(solidType, fireDelay) void PcapEntity::SetCollision(solidType, fireDelay) Sets the collision type of the entity.
SetCollisionGroup(collisionGroup) void PcapEntity::SetCollisionGroup(collisionGroup) Sets the collision group of the entity, determining which other entities it can collide with.
SetAnimation(animationName, fireDelay) void PcapEntity::SetAnimation(animationName, fireDelay) Starts playing the specified animation on the entity.
SetAlpha(opacity, fireDelay) void PcapEntity::SetAlpha(opacity, fireDelay) Sets the alpha (opacity) of the entity, controlling how transparent it appears.
SetColor(colorValue, fireDelay) void PcapEntity::SetColor(colorValue, fireDelay) Sets the color of the entity.
SetSkin(skin, fireDelay) void PcapEntity::SetSkin(skin, fireDelay) Sets the skin of the entity, if the entity has multiple skins available.
SetDrawEnabled(isEnabled, fireDelay) void PcapEntity::SetDrawEnabled(isEnabled, fireDelay) Enables or disables rendering of the entity, controlling whether it is visible in the game world.
IsDrawEnabled() bool PcapEntity::IsDrawEnabled() Checks if the entity is set to be drawn (visible).
SetTraceIgnore(isEnabled) void PcapEntity::SetTraceIgnore(isEnabled) Sets whether the entity should be ignored during traces.
SetSpawnflags(flag) void PcapEntity::SetSpawnflags(flag) Sets the spawnflags of the entity, which can affect its behavior and properties.
SetModelScale(scaleValue, fireDelay) void PcapEntity::SetModelScale(scaleValue, fireDelay) Sets the scale of the entity's model, making it larger or smaller.
GetModelScale() number PcapEntity::GetModelScale() Gets the current model scale of the entity.
SetCenter(vector) void PcapEntity::SetCenter(vector) Sets the center of the entity's bounding box.
SetBBox(minBounds, maxBounds) void PcapEntity::SetBBox(minBounds, maxBounds) Sets the bounding box of the entity using vectors or string representations of vectors.
SetContext(name, value, fireDelay) void PcapEntity::SetContext(name, value, fireDelay) Sets a context value for the entity.
SetUserData(name, value) void PcapEntity::SetUserData(name, value) Stores an arbitrary value associated with the entity.
GetUserData(name) any PcapEntity::GetUserData(name) Retrieves a stored user data value by name.
GetBBox() table PcapEntity::GetBBox() Returns the bounding box of the entity.
GetAABB() table PcapEntity::GetAABB() Returns the axis-aligned bounding box (AABB) of the entity.
GetIndex() number PcapEntity::GetIndex() Returns the index of the entity, which is a unique identifier for the entity within the game.
GetKeyValue(key) any PcapEntity::GetKeyValue(key) Returns the value of a key-value pair for the entity.
GetSpawnflags() number PcapEntity::GetSpawnflags() Returns the spawnflags of the entity.
GetAlpha() number PcapEntity::GetAlpha() Returns the alpha (opacity) value of the entity.
GetColor() string PcapEntity::GetColor() Returns the color of the entity.
GetSkin() number PcapEntity::GetSkin() Returns the skin index of the entity.
GetNamePrefix() string PcapEntity::GetNamePrefix() Returns the prefix of the entity's name.
GetNamePostfix() string PcapEntity::GetNamePostfix() Returns the postfix of the entity's name.
CreateAABB(stat) Vector PcapEntity::CreateAABB(stat) Returns a specific face of the entity's oriented bounding box (AABB) as a vector.
getBBoxPoints() arayLib PcapEntity::getBBoxPoints() Returns an array of vectors representing the 8 vertices of the entity's axis-aligned bounding box (AABB).
getBBoxFaces() arayLib PcapEntity::getBBoxFaces() Retrieves the faces of an entity's bounding box as an array of triangle vertices.

PcapEntity Creator

Provides helper functions for creating and finding entities.

Methods

Function Signature Description
CreateByClassname(classname, keyvalues) PcapEntity entLib::CreateByClassname(classname, keyvalues) Creates an entity of the specified classname with the provided key-value pairs and returns it as a `PcapEntity` object.
CreateProp(classname, origin, modelname, activity, keyvalues) PcapEntity entLib::CreateProp(classname, origin, modelname, activity, keyvalues) Creates a prop entity.
FromEntity(CBaseEntity) PcapEntity entLib::FromEntity(CBaseEntity) Wraps a `CBaseEntity` object in a `PcapEntity` object.
FindByClassname(classname, start_ent) PcapEntity entLib::FindByClassname(classname, start_ent) Finds an entity with the specified classname.
FindByClassnameWithin(classname, origin, radius, start_ent) PcapEntity entLib::FindByClassnameWithin(classname, origin, radius, start_ent) Finds an entity with the specified classname within a given radius from the origin point.
FindByName(targetname, start_ent) PcapEntity entLib::FindByName(targetname, start_ent) Finds an entity with the specified targetname.
FindByNameWithin(targetname, origin, radius, start_ent) PcapEntity entLib::FindByNameWithin(targetname, origin, radius, start_ent) Finds an entity with the specified targetname within a given radius from the origin point.
FindByModel(model, start_ent) PcapEntity entLib::FindByModel(model, start_ent) Finds an entity with the specified model.
FindByModelWithin(model, origin, radius, start_ent) PcapEntity entLib::FindByModelWithin(model, origin, radius, start_ent) Finds an entity with the specified model within a given radius from the origin point.
FindInSphere(origin, radius, start_ent) PcapEntity entLib::FindInSphere(origin, radius, start_ent) Finds entities within a sphere defined by the origin and radius.

ActionScheduler

Provides an enhanced system for creating and managing scheduled events in VScripts.

ScheduleAction

Represents a single action scheduled for execution at a specific time.

Functions

Function Signature Description
Add(eventName, action, timeDelay, args, scope) void ScheduleAction::Add(eventName, action, timeDelay, args, scope) Adds a single action to a scheduled event.
AddInterval(eventName, action, interval, initialDelay, args, scope) void ScheduleAction::AddInterval(eventName, action, interval, initialDelay, args, scope) Adds an action to a scheduled event that will be executed repeatedly.
AddActions(eventName, actions, noSort) void ScheduleAction::AddActions(eventName, actions, noSort) Adds multiple actions to a scheduled event.
Cancel(eventName, delay) void ScheduleAction::Cancel(eventName, delay) Cancels all scheduled actions within an event.
CancelByAction(action, delay) void ScheduleAction::CancelByAction(action, delay) Cancels all scheduled actions that match the given action.
CancelAll() void ScheduleAction::CancelAll() Cancels all scheduled events and actions.
GetEvent(eventName) null ScheduleAction::GetEvent(eventName) Retrieves a scheduled event by name.
IsValid(eventName) bool ScheduleAction::IsValid(eventName) Checks if a scheduled event with the given name exists and has scheduled actions.


Animations

Provides functions for creating various animations in VScripts, such as fading objects in or out, changing their colors, and moving them along paths.

Functions

Function Signature Description
AlphaTransition(entities, startOpacity, endOpacity, time, animSetting) number animate::AlphaTransition(entities, startOpacity, endOpacity, time, animSetting) Creates an animation that smoothly transitions the alpha (opacity) of entities.
ColorTransition(entities, startColor, endColor, time, animSetting) number animate::ColorTransition(entities, startColor, endColor, time, animSetting) Creates an animation that smoothly transitions the color of entities.
PositionTransitionByTime(entities, startPos, endPos, time, animSetting) number animate::PositionTransitionByTime(entities, startPos, endPos, time, animSetting) Creates an animation that moves entities from the starting position to the ending position.
PositionTransitionBySpeed(entities, startPos, endPos, speed, animSetting) number animate::PositionTransitionBySpeed(entities, startPos, endPos, speed, animSetting) Creates an animation that transitions the position of entities over time based on a specified speed.
AnglesTransitionByTime(entities, startAngles, endAngles, time, animSetting) number animate::AnglesTransitionByTime(entities, startAngles, endAngles, time, animSetting) Creates an animation that smoothly changes the angles of entities over time.

animSetting

[Todo]


GameEvents

Provides classes for creating and handling custom game events with triggers, filters, and actions.

Methods

Function Signature Description
GameEvent(eventName, triggerCount, action) GameEvent GameEvent(eventName, triggerCount, action) Creates a new `GameEvent` object.
SetAction(actionFunction) void GameEvents::SetAction(actionFunction) Sets the action function for the event.
SetFilter(filterFunction) void GameEvents::SetFilter(filterFunction) Sets the filter function for the event.
Trigger(args) null GameEvents::Trigger(args) Triggers the event.
ForceTrigger(args) void GameEvents::ForceTrigger(args) Forces the event to trigger.

EventListener

Listens for and handles custom game events.

Methods

Function Signature Description
Notify(eventName, args) null EventListener::Notify(eventName, args) Notifies the listener of a triggered event.
GetEvent(EventName) null EventListener::GetEvent(EventName) Retrieves a `GameEvent` object by name.

HUD

Provides classes for displaying text and hints on the screen using in-game entities.

ScreenText

Represents an on-screen text display.

Methods

Function Signature Description
ScreenText(position, message, holdtime, targetname) ScreenText ScreenText(position, message, holdtime, targetname) Creates a new `ScreenText` object.
Enable() void ScreenText::Enable() Displays the on-screen text.
Disable() void ScreenText::Disable() Hides the on-screen text.
Update() void ScreenText::Update() Updates and redisplays the on-screen text.
SetText(message) void ScreenText::SetText(message) Changes the message of the text display.
SetChannel(channel) void ScreenText::SetChannel(channel) Sets the channel of the text display.
SetColor(color) void ScreenText::SetColor(color) Sets the primary color of the text display as a string.
SetColor2(color) void ScreenText::SetColor2(color) Sets the secondary color of the text display as a string.
SetEffect(index) void ScreenText::SetEffect(index) Sets the effect of the text display.
SetFadeIn(value) void ScreenText::SetFadeIn(value) Sets the fade-in time of the text display in seconds.
SetFadeOut(value) void ScreenText::SetFadeOut(value) Sets the fade-out time of the text display in seconds.
SetHoldTime(time) void ScreenText::SetHoldTime(time) Sets the hold time (duration) of the text display.
SetPos(position) void ScreenText::SetPos(position) Sets the position of the text display.

HintInstructor

Represents a hint display.

Methods

Function Signature Description
HintInstructor(message, holdtime, icon, showOnHud, targetname) HintInstructor HintInstructor(message, holdtime, icon, showOnHud, targetname) Creates a new `HintInstructor` object.
Enable() void HintInstructor::Enable() Displays the hint.
Disable() void HintInstructor::Disable() Hides the hint.
Update() void HintInstructor::Update() Updates and redisplays the hint.
SetText(message) void HintInstructor::SetText(message) Changes the message of the hint.
SetBind(bind) void HintInstructor::SetBind(bind) Sets the bind to display with the hint icon.
SetPositioning(value, entity) void HintInstructor::SetPositioning(value, entity) Sets the positioning of the hint.
SetColor(color) void HintInstructor::SetColor(color) Sets the color of the hint text as a string.
SetIconOnScreen(icon) void HintInstructor::SetIconOnScreen(icon) Sets the icon to display when the hint is on-screen.
SetIconOffScreen(icon) void HintInstructor::SetIconOffScreen(icon) Sets the icon to display when the hint is off-screen.
SetHoldTime(time) void HintInstructor::SetHoldTime(time) Sets the hold time (duration) of the hint.
SetDistance(distance) void HintInstructor::SetDistance(distance) Sets the distance at which the hint is visible.
SetEffects(sizePulsing, alphaPulsing, shaking) void HintInstructor::SetEffects(sizePulsing, alphaPulsing, shaking) Sets the visual effects for the hint.


TracePlus

Provides advanced ray tracing capabilities, including portal support and more precise algorithms.

Functions

Function Signature Description
Cheap(startPos, endPos) CheapTraceResult TracePlus::Cheap(startPos, endPos) Performs a cheap trace from the specified start and end positions.
FromEyes.Cheap(distance, player) CheapTraceResult TracePlus::FromEyes::Cheap(distance, player) Performs a cheap trace from the player's eyes.
PortalCheap(startPos, endPos) CheapTraceResult TracePlus::PortalCheap(startPos, endPos) Performs a cheap trace with portal support.
FromEyes.PortalCheap(distance, player) CheapTraceResult TracePlus::FromEyes.PortalCheap(distance, player) Performs a cheap trace with portal support from the player's eyes.
Bbox(startPos, endPos, ignoreEntities, settings, note) BboxTraceResult TracePlus::Bbox(startPos, endPos, ignoreEntities, settings, note) Performs a bbox cast from the specified start and end positions.
FromEyes.Bbox(distance, player, ignoreEntities, settings) BboxTraceResult TracePlus::FromEyes.Bbox(distance, player, ignoreEntities, settings) Performs a bbox cast from the player's eyes.
PortalBbox(startPos, endPos, ignoreEntities, settings, note) BboxTraceResult TracePlus::PortalBbox(startPos, endPos, ignoreEntities, settings, note) Performs a bbox cast with portal support.
FromEyes.PortalBbox(distance, player, ignoreEntities, settings) BboxTraceResult TracePlus::FromEyes.PortalBbox(distance, player, ignoreEntities, settings) Performs a bbox cast with portal support from the player's eyes.

Settings

Encapsulates settings for ray traces.

Methods

Function Signature Description
new(settingsTable) Settings TracePlus::Settings::new(settingsTable) Creates a new `TracePlus.Settings` object.
SetIgnoredClasses(ignoreClassesArray) void Settings::SetIgnoredClasses(ignoreClassesArray) Sets the list of entity classnames to ignore during traces.
SetPriorityClasses(priorityClassesArray) void Settings::SetPriorityClasses(priorityClassesArray) Sets the list of entity classnames to prioritize during traces.
SetIgnoredModels(ignoredModelsArray) void Settings::SetIgnoredModels(ignoredModelsArray) Sets the list of entity model names to ignore during traces.
SetErrorTolerance(tolerance) void Settings::SetErrorTolerance(tolerance) Sets the maximum allowed distance between trace start and hit positions.
AppendIgnoredClass(className) void Settings::AppendIgnoredClass(className) Appends an entity classname to the list of ignored classes.
AppendPriorityClasses(className) void Settings::AppendPriorityClasses(className) Appends an entity classname to the list of priority classes.
AppendIgnoredModel(modelName) void Settings::AppendIgnoredModel(modelName) Appends an entity model name to the list of ignored models.
GetIgnoreClasses() arrayLib Settings::GetIgnoreClasses() Returns the list of entity classnames to ignore during traces.
GetPriorityClasses() arrayLib Settings::GetPriorityClasses() Returns the list of entity classnames to prioritize during traces.
GetIgnoredModels() arrayLib Settings::GetIgnoredModels() Returns the list of entity model names to ignore during traces.
GetErrorTolerance() number Settings::GetErrorTolerance() Returns the maximum allowed distance between trace start and hit positions.
SetCollisionFilter(filterFunction) void Settings::SetCollisionFilter(filterFunction) Sets a custom function to determine if a ray should hit an entity.
SetIgnoreFilter(filterFunction) void Settings::SetIgnoreFilter(filterFunction) Sets a custom function to determine if an entity should be ignored during a trace.
GetCollisionFilter() null Settings::GetCollisionFilter() Returns the custom collision filter function.
GetIgnoreFilter() null Settings::GetIgnoreFilter() Returns the custom ignore filter function.
ApplyCollisionFilter(entity, note) void Settings::ApplyCollisionFilter(entity, note) Applies the custom collision filter function to an entity.
ApplyIgnoreFilter(entity, note) void Settings::ApplyIgnoreFilter(entity, note) Applies the custom ignore filter function to an entity.
UpdateIgnoreEntities(ignoreEntities, newEnt) void Settings::UpdateIgnoreEntities(ignoreEntities, newEnt) Updates the list of entities to ignore during a trace, including the player entity.

CheapTraceResult

Represents the result of a cheap (fast but less accurate) trace.

Methods

Function Signature Description
GetStartPos() Vector CheapTraceResult::GetStartPos() Returns the start position of the trace.
GetEndPos() Vector CheapTraceResult::GetEndPos() Returns the end position of the trace.
GetHitpos() Vector CheapTraceResult::GetHitpos() Returns the hit position of the trace.
GetFraction() number CheapTraceResult::GetFraction() Returns the fraction of the trace distance where the hit occurred.
DidHit() bool CheapTraceResult::DidHit() Returns `true` if the trace hit something, `false` otherwise.
GetDir() Vector CheapTraceResult::GetDir() Returns the direction vector of the trace.
GetPortalEntryInfo() null CheapTraceResult::GetPortalEntryInfo() Returns the portal entry information.
GetAggregatedPortalEntryInfo() arrayLib CheapTraceResult::GetAggregatedPortalEntryInfo() Returns an `arrayLib` containing all portal entry information for the trace.
GetImpactNormal() Vector CheapTraceResult::GetImpactNormal() Calculates and returns the impact normal of the surface hit by the trace.


BboxTraceResult

Represents the result of a bbox cast (trace with a bounding box).

Methods

Function Signature Description
GetStartPos() Vector BboxTraceResult::GetStartPos() Returns the start position of the trace.
GetEndPos() Vector BboxTraceResult::GetEndPos() Returns the end position of the trace.
GetHitpos() Vector BboxTraceResult::GetHitpos() Returns the hit position of the trace.
GetFraction() number BboxTraceResult::GetFraction() Returns the fraction of the trace distance where the hit occurred.
DidHit() bool BboxTraceResult::DidHit() Returns `true` if the trace hit something, `false` otherwise.
GetDir() Vector BboxTraceResult::GetDir() Returns the direction vector of the trace.
GetPortalEntryInfo() null BboxTraceResult::GetPortalEntryInfo() Returns the portal entry information.
GetAggregatedPortalEntryInfo() arrayLib BboxTraceResult::GetAggregatedPortalEntryInfo() Returns an `arrayLib` containing all portal entry information for the trace.
GetImpactNormal() Vector BboxTraceResult::GetImpactNormal() Calculates and returns the impact normal of the surface hit by the trace.
GetEntity() null BboxTraceResult::GetEntity() Returns the hit entity.
GetEntityClassname() null BboxTraceResult::GetEntityClassname() Returns the classname of the hit entity.
GetIngoreEntities() array BboxTraceResult::GetIngoreEntities() Returns the list of entities that were ignored during the trace.
GetTraceSettings() Settings BboxTraceResult::GetTraceSettings() Returns the settings used for the trace.
GetNote() string BboxTraceResult::GetNote() Returns the optional note associated with the trace.
DidHitWorld() bool BboxTraceResult::DidHitWorld() Returns `true` if the trace hit the world geometry, `false` otherwise.

Utils

The `Utils` module provides a collection of utility functions for script execution, debugging, file operations, and working with entities in VScripts.

Functions

Function Signature Description
dev.DrawEntityBBox(ent, time) void dev.DrawEntityBBox(ent, time) Draws the bounding box of an entity.
dev.drawbox(vector, color, time) void dev.drawbox(vector, color, time) Draws a box at the specified position.
dev.debug(msg) void dev.debug(msg) Logs a debug message to the console.
dev.log(msg) void dev.log(msg) Logs a message to the console only if developer mode is enabled.
dev.warning(msg) void dev.warning(msg) Displays a warning message.
dev.error(msg) void dev.error(msg) Displays an error message.
dev.format(msg, ...) string dev.format(msg, ...) Formats a message string by replacing placeholders (`{}`) with values from the provided arguments.
dev.fprint(msg, ...) void dev.fprint(msg, ...) Formats a message string and then prints the formatted message to the console.
RunScriptCode.delay(script, runDelay, activator, caller, args) void RunScriptCode.delay(script, runDelay, activator, caller, args) Schedules the execution of a script after a specified delay.
RunScriptCode.loopy(script, runDelay, loopCount, outputs) void RunScriptCode.loopy(script, runDelay, loopCount, outputs) Executes a script repeatedly with a specified delay for a given number of loops.
RunScriptCode.setInterval(script, interval, runDelay, eventName) void RunScriptCode.setInterval(script, interval, runDelay, eventName) Schedules the execution of a script recursively at a fixed interval.
RunScriptCode.fromStr(str) void RunScriptCode.fromStr(str) Executes a script from a string.

File

Represents a file object for reading from and writing to files.

Methods

Function Signature Description
File(path) File File(path) Creates a new `File` object.
write(text) void write(text) Appends text to the end of the file.
readlines() array readlines() Reads all lines from the file.
read() string read() Reads the entire contents of the file.
clear() void clear() Clears the contents of the file.
updateInfo() void updateInfo() Updates information about the file.

Macros

Macro functions that provide shortcuts for common operations, such as precaching sounds, retrieving values from tables, etc.

Function Signature Description
macros.Precache(soundPath) void macros.Precache(soundPath) Precaches a sound script or a list of sound scripts for later use.
macros.GetFromTable(table, key, defaultValue) any macros.GetFromTable(table, key, defaultValue) Retrieves a value from a table using the specified key.
macros.PrintIter(iterable) void macros.PrintIter(iterable) Prints the keys and values of an iterable object to the console.
macros.GetDist(vec1, vec2) number macros.GetDist(vec1, vec2) Calculates the distance between two vectors.
macros.StrToVec(str) Vector macros.StrToVec(str) Converts a string representation of a vector (e.g., "x y z") to a `Vector` object.
macros.VecToStr(vec) string macros.VecToStr(vec) Converts a `Vector` object to a string representation (e.g., "x y z").
macros.isEqually(val1, val2) bool macros.isEqually(val1, val2) Checks if two values are equal, handling different data types appropriately.
macros.GetPrefix(name) string macros.GetPrefix(name) Gets the prefix of an entity name, assuming the name is formatted with a "-" separator between the prefix and the rest of the name.
macros.GetPostfix(name) string macros.GetPostfix(name) Gets the postfix of an entity name, assuming the name is formatted with a "-" separator between the prefix and the rest of the name.
macros.GetEyeEndpos(player, distance) Vector macros.GetEyeEndpos(player, distance) Calculates the end position of a ray cast from the player's eyes based on the given distance.
macros.GetVertex(x, y, z, ang) Vector macros.GetVertex(x, y, z, ang) Calculates the position of a vertex of a bounding box.
macros.GetTriangle(v1, v2, v3) table macros.GetTriangle(v1, v2, v3) Creates a representation of a triangle from three given vertices.

Improvements

Improvement of existing functions

Function Signature Description
FrameTime() number FrameTime() Returns the current frame time in seconds.
UniqueString(prefix) string UniqueString(prefix) Generates a unique string with the specified prefix.
EntFireByHandle(target, action, value, delay, activator, caller) void EntFireByHandle(target, action, value, delay, activator, caller) Triggers an entity's input.
GetPlayerEx(index) PcapEntity GetPlayerEx(index) Retrieves a player entity with extended functionality as a `PcapEntity` object.
GetPlayers() arayLib GetPlayers() Returns an array of all players in the game as `PcapEntity` objects.


See also