Skip to content

Tool Core

Vurv edited this page Feb 14, 2021 · 1 revision

Last updated for version v0.3.1

Main Info

This is a sub-addon in VExtensions that adds the ability to interface with a tool created by VExtensions, the E2 Controller.
It allows users to link to your chip, or you to automatically link your e2 controller to the chip in order to cause runOn* events depending on things like left and right clicking alongside reloading.
This is useful to make pseudo-tools with E2.

If you find any bugs, please report them to the Issues page.

Documentation

Functions

runOnE2CSelected(n enable)

If enable is not 0, will set the chip to runOn people selecting the chip with their E2 Controller. Otherwise, will disable it running on that event.

setE2CSelected(n enable)

If enable is not 0, sets your currently selected chip with the E2 Controller to the chip that calls this function.
Else, unselects the current selected chip.

e = e2CSelectedClk()

Returns the player who caused the E2 Controller Selected event.

runOnE2CLeftClick(n enable)

If enable is not 0, will set the chip to run on people who have this chip selected with the E2 Controller pressing left click.
Else, sets the chip to not run on left-clicks.

n = e2CLeftMouseClk()

Returns whether the E2 was run because of a left-click event.

runOnE2CRightClick(n enable)

If enable is not 0, will set the chip to run on people who have this chip selected with the E2 Controller pressing right click.
Else, sets the chip to not run on right-clicks.

n = e2CRightMouseClk()

Returns whether the E2 was run because of a right-click event.

runOnE2CReload(n enable)

If enable is not 0, will set the chip to run on people who have this chip selected with the E2 Controller pressing their reload key.
Else, sets the chip to not run on reload events.

n = e2CReloadClk()

Returns whether the E2 was run because of a reload event.

e = lastE2CUser()

Returns the last user to cause an E2C event.
This is useful if you want to whitelist your tool.

xrd = lastE2CRangerInfo()

Returns the ranger information from the last E2C event.
For example, if the last event was you left clicking a barrel with the e2 controller, it will return that click as a ranger.

Example

@name Hologram Placer Example
@persist HoloInd ColorInd Colors:array SelectedColor:vector
# Example of how to use the E2 Controller from VExtensions.

if(first()){
    runOnE2CLeftClick(1)
    runOnE2CReload(1)
    runOnE2CRightClick(1)

    # These are the colors that will be cycled through when we right click.
    Colors = array(
        vec(255,0,0), # Red
        vec(255,69,0), # Orange
        vec(255,255,0), # Yellow
        vec(0,255,0), # Green
        vec(0,255,200), # Aqua
        vec(0,0,255), # Blue
        vec(180,0,255), # Purple
        vec(255,0,255) # Pink
    )
    ColorInd = 1
    SelectedColor = Colors[1,vector]
}elseif(e2CLeftMouseClk()){
    local RData = lastE2CRangerInfo()
    local Pos = RData:pos()
    local Normal = RData:hitNormal()
    holoCreate(HoloInd,Pos,vec(1,5,5),Normal:toAngle(),SelectedColor)
    HoloInd = (HoloInd+1)%holoMaxAmount()
}elseif(e2CReloadClk()){
    print("Deleted all holos!")
    HoloInd = 0
    holoDeleteAll(1)
}elseif(e2CRightMouseClk()){
    ColorInd = (ColorInd+1)%Colors:count()
    SelectedColor = Colors[ColorInd+1,vector]
    printColor(SelectedColor,"Changed Color!")
}

See more in-depth examples in our Discussions