Skip to content

Controls Gesture

scripts/vscripts/alyxlib/controls/gesture.lua

Properties

version

Gesture.version = value

Default value "v1.2.1"

AutoStart

Gesture.AutoStart = value

Default value false

DebugEnabled

Gesture.DebugEnabled = value

Default value false

Duration

Gesture.Duration = value

Default value 0.3

Gestures

Gesture.Gestures = value

Default value table

CurrentGesture

Gesture.CurrentGesture = value

Default value table

PreviousGesture

Gesture.PreviousGesture = value

Default value table

DicrepancyTolerance

Gesture.DicrepancyTolerance = value

Methods

AddGesture

Adds a new gesture to watch for.

If a finger position is nil, that finger isn't considered.

Gesture:AddGesture(name, index, middle, ring, pinky, thumb)

Parameters

  • name
    string
    Gesture name; overwrites existing one if not unique
  • index
    number, nil
    [0–1] range of the index finger position.
  • middle
    number, nil
    [0–1] range of the middle finger position.
  • ring
    number, nil
    [0–1] range of the ring finger position.
  • pinky
    number, nil
    [0–1] range of the pinky finger position.
  • thumb
    number, nil
    [0–1] range of the thumb finger position.

RemoveGesture

Removes an existing gesture.

Any callbacks registered with the gesture will be unregistered.

Gesture:RemoveGesture(name)

Parameters

  • name
    string
    Gesture name

RemoveGestures

Removes a list of gestures.

Gesture:RemoveGestures(names)

Parameters

  • names
    GestureNames[]
    List of gesture names

GetGesture

Gets the current gesture name of a given hand.

E.g.

Example
local g = Gesture:GetGesture(Player.PrimaryHand)
if g.name == "ThumbsUp" then
    do_something()
end
Gesture:GetGesture(hand)

Parameters

  • hand
    CPropVRHand, 0, 1
    The hand to get the gesture of

Returns - GestureNames Gesture name

GetGestureRaw

Gets the current [0–1] finger curl values of a given hand.

Gesture:GetGestureRaw(hand)

Parameters

  • hand
    CPropVRHand, 0, 1
    The hand to get the gesture of

Returns - GestureTable Gesture values

RegisterCallback

Registers a callback for a specific gesture start/stop.

Gesture:RegisterCallback(kind, hand, gesture, duration, callback, context)

Parameters

  • kind
    "start", "stop"
    Listen for the start or stop of the gesture
  • hand
    CPropVRHand, -1, 0, 1
    The hand to listen to
  • gesture
    GestureNames
    The gesture to listen for
  • duration
    Not implemented
  • callback
    function
    The function to call when the gesture is triggered
  • context (optional)
    any
    Context to pass to the callback

UnregisterCallback

Unregisters a callback function.

Gesture:UnregisterCallback(callback)

Parameters

  • callback
    function
    The function to unregister

Start

Starts the gesture system.

Gesture:Start(on)

Parameters

  • on
    EntityHandle?
    Optional entity to do the tracking on

Stop

Stops the gesture system.

Gesture:Stop()

Types

GestureTable

Gesture table.

Field Type Description
name GestureNames Gesture name
index number|nil [0–1] range of the index finger position
middle number|nil [0–1] range of the middle finger position
ring number|nil [0–1] range of the ring finger position
pinky number|nil [0–1] range of the pinky finger position
thumb number|nil [0–1] range of the thumb finger position

GESTURE_CALLBACK

Field Type Description
kind "start"|"stop" If the gesture was started or stopped
name GestureNames The name of the gesture performed
hand CPropVRHand The hand the gesture was performed on
time number Server time the gesture occurred

Aliases

GestureNames

Value Description
string
"OpenHand"
"ClosedFist"
"ThumbsUp"
"DevilHorns"
"Point"
"FingerGun"
"PinkyOut"
"Shaka"
"MiddleFinger"
"TheShocker"
"Peace"