Utils Common
scripts/vscripts/alyxlib/utils/common.lua
Global variables
| Name | Value |
|---|---|
Util |
table |
Methods
GetHandIdFromTip
Converts vr_tip_attachment from a game event (1,2) into a hand id (0,1) taking primary hand into account.
Parameters
vr_tip_attachment
1,2
Thevr_tip_attachmentvalue from a game event
Returns
- 0|1
The hand id
FindKeyFromValue
This method is deprecated.
Attempts to find a key in tbl pointing to value.
Parameters
tbl
table
The table to searchvalue
any
The value to search for
Returns
- unknown|nil
The key in tbl, or nil if no value was found
TableSize
This method is deprecated.
Returns the size of any table.
Parameters
tbl
table
The table to get the size of
Returns
- integer
The size of the table
Delay
Delays some code.
Parameters
func
function
The function to delaydelay(optional)
number
The delay in seconds (default: 0)
QAngleFromVector
Gets a new QAngle from a Vector.
This simply transfers the raw values from one to the other.
Parameters
vec
Vector
The vector
Returns
- QAngle
The new QAngle
CreateConstraint
Creates a constraint between two entity handles.
Parameters
entity1
EntityHandle
First entity to attachentity2
EntityHandle,nil
Second entity to attach, ornilto attach to worldclass(optional)
string
Class of constraint (default:phys_constraint)properties(optional)
table
Key/value property table for the constraint
Returns
- EntityHandle
The created constraint
CreateExplosion
Creates a damaging explosion effect at a position.
Parameters
origin
Vector
Worldspace positionexplosionType(optional)
ExplosionType
Explosion type (default: "")magnitude(optional)
number
Explosion magnitude (default: 100)radiusOverride(optional)
number
Radius override (default: 0)ignoredEntity(optional)
EntityHandle,string
Targetname to ignore or entity handle with a nameignoredClass(optional)
string
Classname to ignore (default: "")
Choose
Chooses a random value from the provided arguments.
Parameters
...
Returns
- T
Chosen value
VectorFromString
Turns a string of up to three numbers into a vector.
Should have a format of "x y z"
Parameters
str
string
String to parse
Returns
- Vector
Parsed vector
Aliases
ExplosionType
| Value | Description |
|---|---|
"" |
"Default" |
"grenade" |
"Grenade" |
"molotov" |
"Molotov" |
"fireworks" |
"Fireworks" |
"gascan" |
"Gasoline Can" |
"gascylinder" |
"Pressurized Gas Cylinder" |
"explosivebarrel" |
"Explosive Barrel" |
"electrical" |
"Electrical" |
"emp" |
"EMP" |
"shrapnel" |
"Shrapnel" |
"smoke" |
"Smoke Grenade" |
"flashbang" |
"Flashbang" |
"tripmine" |
"Tripmine" |
"ice" |
"Ice" |
"none" |
"None" |
"custom" |
"Custom" |