Skip to content

ComputerCraft integration

getItemFromBlock edited this page Nov 15, 2024 · 5 revisions

Since version 1.2.2, the tweaked lectern controller (obtained by placing a tweaked controller on a lectern) can be used as a CC:Tweaked peripheral.
You can connect it directly to a computer, or to a network like any other peripheral.
The peripheral's name is "tweaked_controller".

Functions

Function Description
hasUser() Returns whether or not a player is using the controller.
getUserUUID() Returns the UUID of the player using the controller.
getButton(index) Returns the value of the button at the given index.
getAxis(index) Returns the value of the axis at the given index.
setFullPrecision(precision) Change the axis precision mode.
isFullPrecision() Returns whether or not the controller uses full precision.

hasUser()

    Returns whether or not a player is using the controller.

    Returns

       boolean - Whether or not a player is using the controller.


getUserUUID()

    Returns the UUID of the player using the controller.

    Returns

       string | nil - The UUID of the player using the controller, or nil if not in use.


getButton(index)

    Returns the value of the button at the given index. See Gamepad buttons for a list of all buttons

    Parameters

       index : number - The index of the button to read value from.

    Returns

       boolean - The state of the button.

    Throws

       If index is outside of the range [1-15]


getAxis(index)

    Returns the value of the axis at the given index. See Gamepad axis for a list of all axis

    Parameters

       index : number - The index of the axis to read value from.

    Returns

       number - The value of the axis.

    Throws

       If index is outside of the range [1-6]


setFullPrecision(precision)

    Change the axis precision mode. By default, the precision will be the same used for redstone output which limits the joystick positions to 15 in each axis.
    With the full precision mode the output is what the controller receives, allowing to fully use the joysticks and triggers.

    It is worth noting that the full precision mode use more bandwidth.
    It requires sending 6*4 bytes of data each time the controller is updated, in contrast to the 4 bytes send in default mode.

    Parameters

       precision : boolean - Whether or not to use full precision mode.


isFullPrecision()

    Returns whether or not the controller is using full precision mode. See setFullPrecision(precision) for more info.

    Returns

       boolean - Whether or not the controller is using full precision mode.

Events

Event Description
controller_start_using Fired when a player starts using the Tweaked Lectern Controller.
controller_stop_using Fired when a player stops using the Tweaked Lectern Controller.

controller_start_using

    Fired when a player starts using the Tweaked Lectern Controller.

    Parameters

       uuid : string - The UUID of the player who started using the controller.


controller_stop_using

    Fired when a player stops using the Tweaked Lectern Controller.

    Parameters

       uuid : string - The UUID of the player who stopped using the controller.

Gamepad buttons

Below are the mappings between the controller's buttons and the peripheral's getButton(index) IDs.

Button ID Button Name
1 Face Button Down
2 Face Button Right
3 Face Button Left
4 Face Button Up
5 Left Bumper
6 Right Bumper
7 Back
8 Start
9 Guide
10 Left Stick
11 Right Stick
12 D-Pad Up
13 D-Pad Right
14 D-Pad Down
15 D-Pad Left

Gamepad axis

Below are the mappings between the controller's axisand the peripheral's getAxis(index) IDs.

Axis ID Axis Name
1 Left Joystick X
2 Left Joystick Y
3 Right Joystick X
4 Right Joystick Y
5 Left Trigger
6 Right Trigger
Clone this wiki locally