PCapture-LIB v3.4 Short Documentation
This document provides a concise overview of PCapture-Lib's modules and their key functionalities.
Each module's section below links to the corresponding readme.md
within the module directory for detailed information and examples. You can also navigate to specific sections within each module's documentation by clicking on the header or the function/method.
Table of Contents
The following console commands are available for debugging and managing the library during runtime:
PCapLib_version
: Prints the current library version.
PCapLib_level_trace
: Sets the logger level to Trace
.
PCapLib_level_debug
: Sets the logger level to Debug
.
PCapLib_level_info
: Sets the logger level to Info
.
PCapLib_level_warn
: Sets the logger level to Warning
.
PCapLib_level_error
: Sets the logger level to Error
.
PCapLib_level_off
: Sets the logger level to Off
.
PCapLib_schedule_list
: Lists all currently scheduled events.
PCapLib_schedule_clear
: Cancels all currently scheduled events.
PCapLib_vscript_event_list
: Lists all registered script events.
PCapLib_players_list
: Lists all current players.
Enhances ray tracing capabilities, including portal and custom trace settings.
Class/Type/Method
Description
TracePlus.Settings
Encapsulates trace settings.
new(settingsTable: table)
Creates a TracePlus.Settings
object.
SetIgnoredClasses(ignoreClassesArray: ArrayEx)
Sets ignored classes.
SetPriorityClasses(priorityClassesArray: ArrayEx)
Sets priority classes.
SetIgnoredModels(ignoredModelsArray: ArrayEx)
Sets ignored models.
SetDepthAccuracy(value: number)
Sets depth accuracy.
SetBynaryRefinement(bool: bool)
Sets binary refinement.
AppendIgnoredClass(className: string)
Appends ignored class.
AppendPriorityClasses(className: string)
Appends to priority classes.
AppendIgnoredModel(modelName: string)
Appends ignored model.
SetCollisionFilter(filterFunction: function)
Sets collision filter.
SetIgnoreFilter(filterFunction: function)
Sets ignore filter.
GetIgnoreClasses() -> ArrayEx
Returns ignored classes.
GetPriorityClasses() -> ArrayEx
Returns priority classes.
GetIgnoredModels() -> ArrayEx
Returns ignored models.
GetCollisionFilter() -> function
Returns collision filter function.
GetIgnoreFilter() -> function
Returns ignore filter function.
ApplyCollisionFilter(entity: pcapEntity, note: string)
Applies collision filter.
ApplyIgnoreFilter(entity: pcapEntity, note: string)
Applies ignore filter.
UpdateIgnoreEntities(ignoreEntities: table, newEnt: pcapEntity)
Updates ignored entities.
Class/Method
Description
CheapTraceResult
Result of a cheap trace.
GetStartPos() -> Vector
Returns start position.
GetEndPos() -> Vector
Returns end position.
GetHitpos() -> Vector
Returns hit position.
GetFraction() -> number
Returns hit fraction.
DidHit() -> bool
Returns true if hit.
GetDir() -> Vector
Returns trace direction.
GetPortalEntryInfo() -> CheapTraceResult
Returns portal entry info.
GetAggregatedPortalEntryInfo() -> ArrayEx
Returns all portal entry info.
GetImpactNormal() -> Vector
Returns impact normal.
BboxTraceResult
Result of a bbox cast.
GetEntity() -> pcapEntity
Returns hit entity.
GetEntityClassname() -> string
Returns hit entity classname.
GetIngoreEntities() -> table
Returns ignored entities.
GetTraceSettings() -> TraceSettings
Returns trace settings.
GetNote() -> string
Returns trace note.
DidHitWorld() -> bool
Returns true if hit world geometry.
Function
Description
CalculateImpactNormal(startPos: Vector, hitPos: Vector) -> Vector
Impact normal for world geometry.
CalculateImpactNormalFromBbox(startPos: Vector, hitPos: Vector, hitEntity: pcapEntity) -> Vector
Impact normal from bounding box.
CalculateImpactNormalFromBbox2(startPos: Vector, hitPos: Vector, hitEntity: pcapEntity) -> Vector
Fallback bounding box normal.
Provides enhanced data structures.
Function
Description
CreateByClassname(classname: string, keyvalues: table) -> pcapEntity
Creates entity.
CreateProp(classname: string, origin: Vector, modelname: string, activity: number, keyvalues: table) -> pcapEntity
Creates prop.
FromEntity(CBaseEntity: CBaseEntity) -> pcapEntity
pcapEntity
from CBaseEntity
.
FindByClassname(classname: string, start_ent: CBaseEntity|pcapEntity) -> pcapEntity
Finds entity by classname.
FindByClassnameWithin(classname: string, origin: Vector, radius: number, start_ent: CBaseEntity|pcapEntity) -> pcapEntity
Finds entity within radius.
FindByName(targetname: string, start_ent: CBaseEntity|pcapEntity) -> pcapEntity
Finds entity by name.
FindByNameWithin(targetname: string, origin: Vector, radius: number, start_ent: CBaseEntity|pcapEntity) -> pcapEntity
Finds entity by name within radius.
FindByModel(model: string, start_ent: CBaseEntity|pcapEntity) -> pcapEntity
Finds entity by model.
FindByModelWithin(model: string, origin: Vector, radius: number, start_ent: CBaseEntity|pcapEntity) -> pcapEntity
Finds entity by model within radius.
FindInSphere(origin: Vector, radius: number, start_ent: CBaseEntity|pcapEntity) -> pcapEntity
Finds entities in sphere.
Provides the pcapEntity
class, extending CBaseEntity
functionality.
Category
Methods
State/Lifecycle
GetIndex() -> number
, IsValid() -> bool
, IsPlayer() -> bool
, isEqually(other: pcapEntity|CBaseEntity) -> bool
, Destroy(fireDelay: number, eventName: string)
, Kill(fireDelay: number, eventName: string)
, Dissolve(fireDelay: number, eventName: string)
, Disable(fireDelay: number, eventName: string)
, Enable(fireDelay: number, eventName: string)
, IsDrawEnabled() -> bool
Naming
SetName(name: string, fireDelay: number, eventName: string)
, SetUniqueName(prefix: string, fireDelay: number, eventName: string)
, GetNamePrefix() -> string
, GetNamePostfix() -> string
Player
EyePosition() -> Vector
, EyeAngles() -> Vector
, EyeForwardVector() -> Vector
Transform
SetAngles(x: number, y: number, z: number)
, SetAbsAngles(angles: Vector)
, SetCenter(vector: Vector)
, SetParent(parentEnt: string|CBaseEntity|pcapEntity, fireDelay: number, eventName: string)
, GetParent() -> pcapEntity
, SetModelScale(scaleValue: number, fireDelay: number, eventName: string)
, GetModelScale() -> number
Appearance
SetAlpha(opacity: number, fireDelay: number, eventName: string)
, SetColor(colorValue: string|Vector, fireDelay: number, eventName: string)
, SetSkin(skin: number, fireDelay: number, eventName: string)
, SetDrawEnabled(isEnabled: bool, fireDelay: number, eventName: string)
, SetAnimation(animationName: string, fireDelay: number, eventName: string)
, GetAlpha() -> number
, GetColor() -> string
, GetSkin() -> number
, GetPartnerInstance() -> pcapEntity
KeyValues/Data
SetKeyValue(key: string, value: any, fireDelay: number, eventName: string)
, SetUserData(name: string, value: any)
, GetUserData(name: string) -> any
, GetKeyValue(key: string) -> any
, SetContext(name: string, value: any, fireDelay: number, eventName: string)
Collision
SetCollision(solidType: number, fireDelay: number, eventName: string)
, SetCollisionGroup(collisionGroup: number, fireDelay: number, eventName: string)
, SetTraceIgnore(isEnabled: bool, fireDelay: number, eventName: string)
, SetSpawnflags(flag: number, fireDelay: number, eventName: string)
, GetSpawnflags() -> number
Sound
EmitSound(soundName: string, fireDelay: number, eventName: string)
, EmitSoundEx(soundName: string, volume: number, looped: bool, fireDelay: number, eventName: string)
, StopSoundEx(soundName: string, fireDelay: number, eventName: string)
Outputs/Inputs
AddOutput(outputName: string, target: string|CBaseEntity|pcapEntity, input: string, param: string, delay: number, fires: number)
, ConnectOutputEx(outputName: string|function, script: string, delay: number, fires: number)
, SetInputHook(inputName: string, closure: function)
BBox/Position
SetBBox(minBounds: Vector|string, maxBounds: Vector|string)
, GetBBox() -> table
, IsSquareBbox() -> bool
, GetAABB() -> table
, CreateAABB(stat: number) -> Vector
, getBBoxPoints() -> array
, getBBoxFaces() -> array
Provides utility functions.
Function
Description
DrawEntityBBox(ent: pcapEntity|CBaseEntity, color: Vector, time: number)
Draws bounding box.
DrawEntityAABB(ent: pcapEntity|CBaseEntity, color: Vector, time: number)
Draws AABB.
drawbox(vector: Vector, color: Vector, time: number)
Draws a box.
trace(msg: string, ...)
Trace log.
debug(msg: string, ...)
Debug log.
info(msg: string, ...)
Info log.
warning(msg: string, ...)
Warning log.
error(msg: string, ...)
Error log.
Macro
Description
Precache(soundPath: string|array|ArrayEx)
Precaches sound(s).
GetSoundDuration(soundName: string) -> number
Gets sound duration.
CreateAlias(key: string, action: string)
Creates a simple console alias.
CreateCommand(key: string, command: string)
Creates a console command.
format(msg: string, ...) -> string
Formats message string.
fprint(msg: string, ...)
Formats and prints.
CompileFromStr(funcBody: string, ...)
Compiles a function from a string representation.
GetFromTable(table: table, key: any, defaultValue: any) -> any
Gets from table with default.
GetKeys(table: object) -> List
Returns keys from table as List.
GetValues(table: object) -> List
Returns values from table as List.
InvertTable(table: table) -> table
Inverts table.
PrintIter(iterable: iterable)
Prints iterable.
MaskSearch(iter: array|ArrayEx, match: string) -> number
Mask search in array.
GetRectangle(v1: Vector, v2: Vector, v3: Vector, v4: Vector) -> table
Creates rectangle object.
PointInBBox(point: Vector, bMin: Vector, bMax: Vector) -> bool
Point in bbox check.
PointInBounds(point: Vector) -> bool
Point in world's bounds check.
Range(start: number, end: number, step: number) -> List
Creates number range as List.
RangeIter(start: number, end: number, step: number) -> iterator
Creates number range iterator.
GetDist(vec1: Vector, vec2: Vector) -> number
Distance between vectors.
StrToVec(str: string) -> Vector
String to vector.
VecToStr(vec: Vector, sep: String) -> string
Vector to string.
isEqually(val1: any, val2: any) -> bool
Equality check.
DeepCopy(container: iter) -> iter
Deep copy of a container.
GetPrefix(name: string) -> string
Name prefix.
GetPostfix(name: string) -> string
Name postfix.
GetEyeEndpos(player: CBaseEntity|pcapEntity, distance: number) -> Vector
Eye raycast endpoint.
GetVertex(x: Vector, y: Vector, z: Vector, ang: Vector) -> Vector
BBox vertex position.
GetTriangle(v1: Vector, v2: Vector, v3: Vector) -> table
Creates triangle representation.
BuildAnimateFunction(name: string, propertySetterFunc: function, valueCalculator: function) -> function
Creates a new animation function.
BuildRTAnimateFunction(name: string, propertySetterFunc: function, valueCalculator: function) -> function
Creates a new real-time animation function.
Provides enhanced event scheduling.
Function
Description
Add(eventName: string, action: string|function, timeDelay: number, args: array, scope: object)
Adds scheduled event.
AddInterval(eventName: string, action: string|function, interval: number, initialDelay: number, args: array, scope: any)
Adds interval event.
AddActions(eventName: string, actions: array|List, noSort: bool)
Adds multiple actions.
Cancel(eventName: string, delay: number)
Cancels event.
TryCancel(eventName: string, delay: number) -> bool
Tries to cancel event.
CancelByAction(action: string|function, delay: number)
Cancels by action.
CancelAll()
Cancels all events.
GetEvent(eventName: string) -> List
Gets event actions.
IsValid(eventName: string) -> bool
Checks event validity.
Provides animation functions.
Class/Function
Description
AnimEvent(name: string, settings: table, entities: array|CBaseEntity|pcapEntity, time: number)
Animation event data.
applyAnimation(animInfo: AnimEvent, valueCalculator: function, propertySetter: function, vars: any, transitionFrames: number)
Applies animation.
applyRTAnimation(animInfo: AnimEvent, valueCalculator: function, propertySetter: function, vars: any, transitionFrames: number)
Applies real-time animation.
_applyRTAnimation(animInfo: AnimEvent, valueCalculator: function, propertySetter: function, vars: any, transitionFrames: number)
Internal function for real-time animation.
Function
Description
AlphaTransition(entities: array|CBaseEntity|pcapEntity, startOpacity: number, endOpacity: number, time: number, animSetting: table) -> number
Animates alpha.
ColorTransition(entities: array|CBaseEntity|pcapEntity, startColor: string|Vector, endColor: string|Vector, time: number, animSetting: table) -> number
Animates color.
PositionTransitionByTime(entities: array|CBaseEntity|pcapEntity, startPos: Vector, endPos: Vector, time: number, animSetting: table) -> number
Animates position by time.
PositionTransitionBySpeed(entities: array|CBaseEntity|pcapEntity, startPos: Vector, endPos: Vector, speed: number, animSetting: table) -> number
Animates position by speed.
AnglesTransitionByTime(entities: array|CBaseEntity|pcapEntity, startAngles: Vector, endAngles: Vector, time: number, animSetting: table) -> number
Animates angles.
Provides various mathematical functions and objects.
Provides basic algebraic functions.
Function
Description
min(...)
Finds minimum value.
max(...)
Finds maximum value.
clamp(number: number, min: number, max: number)
Clamps a number.
round(value: number, precision: number)
Rounds a number.
Sign(x: number)
Sign of number (-1, 0, or 1)
copysign(value: number, sign: number)
Copies sign to value.
RemapVal(val: number, A: number, B: number, C: number, D: number)
Remaps value between ranges.
Provides utility functions for working with vectors.
Function
Description
vector.isEqually(vec1: Vector, vec2: Vector)
Vector equality check (integers).
vector.isEqually2(vec1: Vector, vec2: Vector, precision: number)
Vector approximate equality.
vector.mul(vec1: Vector, vec2: Vector)
Element-wise multiplication.
vector.rotate(vec: Vector, angle: Vector)
Vector rotation.
vector.unrotate(vec: Vector, angle: Vector)
Vector unrotation.
vector.random(min: Vector|number, max: Vector|number)
Random vector generation.
vector.reflect(dir: Vector, normal: Vector)
Reflects vector off normal.
vector.clamp(vec: Vector, min: number, max: number)
Clamps vector components.
vector.resize(vec: Vector, newLength: number)
Resizes vector to new length.
vector.round(vec: Vector, precision: number)
Rounds vector components.
vector.sign(vec: Vector)
Returns vector of component signs.
vector.abs(vector: Vector)
Returns vector with absolute components.
Provides linear interpolation functions.
| Function | Description |
|---|---|math
| lerp.number(start: number, end: number, t: number)
| Number interpolation. |
| lerp.vector(start: Vector, end: Vector, t: number)
| Vector interpolation. |
| lerp.color(start: string\|Vector, end: string\|Vector, t: number)
| Color interpolation. |
| lerp.sVector(start: Vector, end: Vector, t: number)
| Spherical vector interpolation. |
| lerp.SmoothStep(edge0: number, edge1: number, x: number)
| Smoothstep interpolation. |
| lerp.FLerp(f1: number, f2: number, i1: number, i2: number, x: number)
| Custom parameter interpolation. |
Provides various easing functions.
Function
Description
ease.InSine(t: number)
, ease.OutSine(t: number)
, ease.InOutSine(t: number)
Sine easing functions.
ease.InQuad(t: number)
, ease.OutQuad(t: number)
, ease.InOutQuad(t: number)
Quadratic easing functions.
ease.InCubic(t: number)
, ease.OutCubic(t: number)
, ease.InOutCubic(t: number)
Cubic easing functions.
ease.InQuart(t: number)
, ease.OutQuart(t: number)
, ease.InOutQuart(t: number)
Quartic easing functions.
ease.InQuint(t: number)
, ease.OutQuint(t: number)
, ease.InOutQuint(t: number)
Quintic easing functions.
ease.InExpo(t: number)
, ease.OutExpo(t: number)
, ease.InOutExpo(t: number)
Exponential easing functions.
ease.InCirc(t: number)
, ease.OutCirc(t: number)
, ease.InOutCirc(t: number)
Circular easing functions.
ease.InBack(t: number)
, ease.OutBack(t: number)
, ease.InOutBack(t: number)
Back easing functions.
ease.InElastic(t: number)
, ease.OutElastic(t: number)
, ease.InOutElastic(t: number)
Elastic easing functions.
ease.InBounce(t: number)
, ease.OutBounce(t: number)
, ease.InOutBounce(t: number)
Bounce easing functions.
Provides quaternion operations.
Provides matrix operations.