Module vr

This peripheral is added by CC: VR and allows CC: Tweaked computers to access a bound player's VR controllers and headset via Vivecraft!

This addon also includes CC: Advanced Math which provides the quaternion API used for the rotation in body part data.

Usage:

    -- assuming the peripheral block is to the left of the computer
    local vr = peripheral.wrap("left")
    

Functions

hasBoundPlayer () Determines whether a player has been bound ot the peripheral.
isInVR () Determines whether the bound player is in VR mode.
isLeftHanded () Determines whether the bound player in VR has set themselves as left-handed.
isSeated () Determines whether the bound player in VR is seated.
isLeftHanded () Determines whether the bound player in VR is crawling.
getHeightScale () Gets the height scale of the bound player in VR mode.
getWorldScale () Gets the world scale of the bound player in VR mode.
getFBTMode () Gets what Full Body Tracking mode the bound player is in.
triggerHapticPulse (bodyPart, duration[, frequency=160[, amplitude=1[, delay=0]]]) Triggers a haptic pulse for the bound player on the targeted body part
getHead () Gets the positioning and orientation data of the headset.
getMainHand () Gets the positioning and orientation data of the main hand controller.
getOffhand () Gets the positioning and orientation data of the off-hand controller.
getBodyPartData (bodyPart) Gets the positioning and orientation data of the body part.


Functions

hasBoundPlayer ()
Determines whether a player has been bound ot the peripheral.

Returns:

    boolean whether a player has been bound

Usage:

    if vr.hasBoundPlayer() then
        print("Player is Bound!")
    end
isInVR ()
Determines whether the bound player is in VR mode.

Returns:

    boolean whether the bound player is in VR mode

Raises:

This method errors if there is no bound player.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        print("Player is Bound and in VR!")
    end
isLeftHanded ()
Determines whether the bound player in VR has set themselves as left-handed.

Returns:

    boolean whether the bound player in VR is left-handed

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() and vr.isLeftHanded() then
        print("Player is Bound, in VR, and left-handed!")
    end
isSeated ()
Determines whether the bound player in VR is seated.

Returns:

    boolean whether the bound player in VR is seated

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() and vr.isSeated() then
        print("Player is Bound, in VR, and seated!")
    end
isLeftHanded ()
Determines whether the bound player in VR is crawling.

Returns:

    boolean whether the bound player in VR is crawling

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() and vr.isCrawling() then
        print("Player is Bound, in VR, and crawling!")
    end
getHeightScale ()
Gets the height scale of the bound player in VR mode.

Returns:

    number the height scale of the bound VR player

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        print("Height Scale: " .. tostring(vr.getHeightScale()))
    end
getWorldScale ()
Gets the world scale of the bound player in VR mode.

Returns:

    number the world scale of the bound VR player

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        print("World Scale: " .. tostring(vr.getWorldScale()))
    end
getFBTMode ()
Gets what Full Body Tracking mode the bound player is in.

Returns:

    string or nil the FBT mode enum value or nil if the pose is not loaded

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        print("Full Body Tracking: " .. vr.getFBTMode())
    end
triggerHapticPulse (bodyPart, duration[, frequency=160[, amplitude=1[, delay=0]]])
Triggers a haptic pulse for the bound player on the targeted body part

Parameters:

  • bodyPart string the body part enum value
  • duration number the duration of the pulse in seconds
  • frequency number the frequency of the pulse (default 160)
  • amplitude number the amplitude of the pulse (default 1)
  • delay number the delay of the pulse in seconds (default 0)

Raises:

This method errors if there is no bound player or if the provided body part enum string is invalid.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        br.triggerHapticPulse("MAIN_HAND", 1)
    end
getHead ()
Gets the positioning and orientation data of the headset.

Returns:

    table or nil the data of the headset (pos, dir, rotation, pitch, roll, and yaw in a table) or nil if the pose is not loaded

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        local data = vr.getHead()
        if data ~= nil then
            print("Position: " .. tostring(data.pos)) -- this is a CC: Tweaked vector (0,0,0)
            print("Direction: " .. tostring(data.dir)) -- this is a CC: Tweaked vector (0,0,0)
            print("Rotation: " .. tostring(data.rotation)) -- this is a CC: Advanced Math quaternion (1 + 0i + 0j + 0k)
            print("Pitch: " .. tostring(data.pitch))
            print("Roll: " .. tostring(data.roll))
            print("Yaw: " .. tostring(data.yaw))
        end
    end
getMainHand ()
Gets the positioning and orientation data of the main hand controller.

Returns:

    table or nil the data of the main hand controller (pos, dir, rotation, pitch, roll, and yaw in a table) or nil if the pose is not loaded

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        local data = vr.getMainHand()
        if data ~= nil then
            print("Position: " .. tostring(data.pos)) -- this is a CC: Tweaked vector (0,0,0)
            print("Direction: " .. tostring(data.dir)) -- this is a CC: Tweaked vector (0,0,0)
            print("Rotation: " .. tostring(data.rotation)) -- this is a CC: Advanced Math quaternion (1 + 0i + 0j + 0k)
            print("Pitch: " .. tostring(data.pitch))
            print("Roll: " .. tostring(data.roll))
            print("Yaw: " .. tostring(data.yaw))
        end
    end
getOffhand ()
Gets the positioning and orientation data of the off-hand controller.

Returns:

    table or nil the data of the off-hand controller (pos, dir, rotation, pitch, roll, and yaw in a table) or nil if the pose is not loaded

Raises:

This method errors if there is no bound player or if the bound player is not in VR mode.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        local data = vr.getOffhand()
        if data ~= nil then
            print("Position: " .. tostring(data.pos)) -- this is a CC: Tweaked vector (0,0,0)
            print("Direction: " .. tostring(data.dir)) -- this is a CC: Tweaked vector (0,0,0)
            print("Rotation: " .. tostring(data.rotation)) -- this is a CC: Advanced Math quaternion (1 + 0i + 0j + 0k)
            print("Pitch: " .. tostring(data.pitch))
            print("Roll: " .. tostring(data.roll))
            print("Yaw: " .. tostring(data.yaw))
        end
    end
getBodyPartData (bodyPart)
Gets the positioning and orientation data of the body part.

Parameters:

  • bodyPart string the body part enum value

Returns:

    table or nil the data of the body part (pos, dir, rotation, pitch, roll, and yaw in a table) or nil if the pose is not loaded

Raises:

This method errors if there is no bound player, if the bound player is not in VR mode, or if the provided body part enum string is invalid.

Usage:

    if vr.hasBoundPlayer() and vr.isInVR() then
        local data = vr.getBodyPartData("MAIN_HAND")
        if data ~= nil then
            print("Position: " .. tostring(data.pos)) -- this is a CC: Tweaked vector (0,0,0)
            print("Direction: " .. tostring(data.dir)) -- this is a CC: Tweaked vector (0,0,0)
            print("Rotation: " .. tostring(data.rotation)) -- this is a CC: Advanced Math quaternion (1 + 0i + 0j + 0k)
            print("Pitch: " .. tostring(data.pitch))
            print("Roll: " .. tostring(data.roll))
            print("Yaw: " .. tostring(data.yaw))
        end
    end
generated by LDoc 1.5.0 Last updated 2026-05-08 15:32:45