Skip to main content

Action

An action in the Figura Action Wheel

Actions are either interacted by clicking and scrolling, which also being able to be toggleable

For the entire page assume:

local myPage = action_wheel:newPage()
local myAction = myPage:newAction()

Action Events

setOnLeftClick()

Aliases: onLeftClick()

Sets the function that is executed when the left mouse button is clicked

The function has one argument

The first argument is this action itself

See the action wheel tutorial for a full example.

setOnLeftClick(leftFunction)

Parameters:

NameTypeDescriptionDefault
leftFunctionFunctionThe function that will be run when the action is left clickedRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

function pings.lefty()
print("I left clicked this button!")
end

myAction:setOnLeftClick(pings.lefty)

setOnRightClick()

Aliases: onRightClick()

Sets the function that is executed when the right mouse button is clicked

The function has one argument

The first argument is this action itself

setOnRightClick(rightFunction)

Parameters:

NameTypeDescriptionDefault
rightFunctionFunctionThe function that will be run when the action is right clickedRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

function pings.righty()
print("I right clicked this button!")
end

myAction:setOnRightClick(pings.righty)

setOnToggle()

Aliases: onToggle()

Sets the function that is executed when the Action is toggled

The function has two arguments

The first argument is toggle state of this action

The second argument is this action itself

See the action wheel tutorial for a full example.

setOnToggle(toggleFunction)

Parameters:

NameTypeDescriptionDefault
toggleFunctionFunctionThe function that will be run when the action is toggledRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

function pings.setVisible(state)
models:setVisible(state) -- toggles the visibility of the entire avatar because state swaps between true and false every click
end

myAction:setOnToggle(pings.setVisible)

setOnUntoggle()

Aliases: onUntoggle()

warning

This method is a noob trap, anything it can do setOnToggle does better because setOnToggle also runs its function when untoggled

Sets the function that is executed when the Action is untoggled

The function has two arguments

The first argument is toggle state of this action

The second argument is this action itself

setOnUntoggle(toggleFunction)

Parameters:

NameTypeDescriptionDefault
toggleFunctionFunctionThe function that will be run when the action is untoggledRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

function pings.toggley(bool)
print('This is always true: ', .. bool) -- this is always true because setOnUnToggle changes the behavior of setOnToggle. Without setOnUnToggle this would swap between true and false
end

function pings.untoggley(bool)
print('This is always false: ' .. bool)
end

local myAction = myPage:newAction()
:setOnToggle(pings.toggley)
:setOnUntoggle(pings.untoggley)

setOnScroll()

Aliases: onScroll()

Sets the function that is executed when the mouse is scrolled

The function has two arguments

The first argument is mouse wheel direction

The second argument is this action itself

setOnScroll(scrollFunction)

Parameters:

NameTypeDescriptionDefault
scrollFunctionFunctionThe function that will be run when the action is scrolled overRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

function pings.scrolling(dir)
log(dir)
if dir > 0 then
log("Scrolled up")
else
log("Scrolled down")
end
end

myAction:setOnScroll(pings.scrolling)

Appearance

setColor()

Aliases: color()

Sets the background color of the Action

setColor(r, g, b)

Parameters:

NameTypeDescriptionDefault
rNumberThe red value of the background, between 0 and 10
gNumberThe green value of the background, between 0 and 10
bNumberThe blue value of the background, between 0 and 10

Returns:

TypeDescription
ActionReturns self for chaining

Example (Overload 2):

myAction:setColor(255 / 255, 192 / 155, 203 / 255)

getColor()

Gets this Action's background color

getColor()

Returns:

TypeDescription
Vector3The RGB background color for this action

Example:

myAction:getColor()

setHoverColor()

Aliases: hoverColor()

Sets the background color of the Action when it is being hovered

setHoverColor(r, g, b)

Parameters:

NameTypeDescriptionDefault
rNumberThe red value of the background, between 0 and 10
gNumberThe green value of the background, between 0 and 10
bNumberThe blue value of the background, between 0 and 10

Returns:

TypeDescription
ActionReturns self for chaining

Example:

myAction:setHoverColor(255 / 255, 192 / 155, 203 / 255)

getHoverColor()

Gets this Action's background hover color

getHoverColor()

Returns:

TypeDescription
Vector3The RGB background hover color for this action

Example:

myAction:getHoverColor()

setHoverItem()

Aliases: hoverItem()

Sets the item of the Action when it is being hovered

setHoverItem(item)

Parameters:

NameTypeDescriptionDefault
itemStringThe item id for the item to be set"minecraft:air"

Returns:

TypeDescription
ActionReturns self for chaining

Example (Overload 2):

myAction:setHoverItem("diamond")

setHoverTexture()

Aliases: hoverTexture()

Sets a Custom Texture to render while this Action is being hovered

All values are measured in pixels

Default UV is 0, 0, the default dimensions are the texture dimensions and the default scale of 1

setHoverTexture(texture)

Parameters:

NameTypeDescriptionDefault
textureTextureThe texture that's shown in the actionRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

-- basic
myAction:setHoverTexture(textures["myTexture"])

-- advanced
myAction:setHoverTexture(textures["myTexture"], 16, 32, nil, nil, 2)

setItem()

Aliases: item()

Sets the item of the Action

setItem(item)

Parameters:

NameTypeDescriptionDefault
itemStringThe item id for the item to be set"minecraft:air"

Returns:

TypeDescription
ActionReturns self for chaining

Example (Overload 2):

myAction:setItem("minecraft:stone")

setTexture()

Aliases: texture()

Sets a Custom Texture to render in this Action

All values are measured in pixels

Default UV is 0, 0, the default dimensions are the texture dimensions and the default scale of 1

setTexture(texture)

Parameters:

NameTypeDescriptionDefault
textureTextureThe texture that's shown in the actionRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

-- basic
myAction:setTexture(textures["myTexture"])

-- advanced
myAction:setTexture(textures["myTexture"], 16, 32, nil, nil, 2)

setTitle()

Aliases: title()

Sets the title of the Action

setTitle(title)

Parameters:

NameTypeDescriptionDefault
titleStringThe title of the action, shown when the action is hovered overnil

Returns:

TypeDescription
ActionReturns self for chaining

Example (Overload 2):

myAction:setTitle("Click me!")

getTitle()

Gets this Action title

getTitle()

Returns:

TypeDescription
StringThe title of the action, shown when the action is hovered over

Example:

myAction:getTitle()

Toggle Specific

setToggleColor()

Aliases: toggleColor()

Sets the color of the Action when it is toggled

setToggleColor(r, g, b)

Parameters:

NameTypeDescriptionDefault
rNumberThe red value of the toggle background, between 0 and 10
gNumberThe green value of the toggle background, between 0 and 10
bNumberThe blue value of the toggle background, between 0 and 10

Returns:

TypeDescription
ActionReturns self for chaining

Example:

myAction:setToggleColor(0, 128 / 255, 128 / 255)

getToggleColor()

Gets this Action toggled color

getToggleColor()

Returns:

TypeDescription
Vector3The RGB value of the toggle background, with each value between 0 and 1

Example:

myAction:getToggleColor()

setToggleItem()

Aliases: toggleItem()

Sets the item of the Action when it is toggled

setToggleItem(item)

Parameters:

NameTypeDescriptionDefault
itemStringThe item id for the item to be set when toggled"minecraft:air"

Returns:

TypeDescription
ActionReturns self for chaining

Example (Overload 2):

myAction:setToggleItem("armor_stand")

setToggleTexture()

Aliases: toggleTexture()

Sets a Custom Texture to render in this Action when it is toggled

All values are measured in pixels

Default UV is 0, 0, the default dimensions are the texture dimensions and the default scale of 1

setToggleTexture(texture)

Parameters:

NameTypeDescriptionDefault
textureTextureThe texture that's shown in the actionRequired

Returns:

TypeDescription
ActionReturns self for chaining

Example:

-- basic
myAction:setToggleTexture(textures["myToggleTexture"])

-- advanced
myAction:setToggleTexture(textures["myTexture"], 16, 32, nil, nil, 2)

setToggleTitle()

Aliases: toggleTitle()

Sets the title of the Action when it is toggled

setToggleTitle(title)

Parameters:

NameTypeDescriptionDefault
titleStringThe title of the action, shown when the action is hovered overnil

Returns:

TypeDescription
ActionReturns self for chaining

Example:

myAction:setToggleTitle("Stand")

getToggleTitle()

Gets this Action toggled title

getToggleTitle()

Returns:

TypeDescription
StringThe title of the action, shown when the action is hovered over

Example:

myAction:getToggleTitle()

setToggled()

Aliases: toggled()

Sets the toggle state of the Action

setToggled(bool)

Parameters:

NameTypeDescriptionDefault
boolBooleanIf true the toggle will be on, and if false it will be offfalse

Returns:

TypeDescription
ActionReturns self for chaining

Example:

myAction:setToggled(true)

isToggled()

Checks if the Action is toggled or not

isToggled()

Returns:

TypeDescription
BooleanIf true the toggle is on, and if false it is off

Example:

myAction:isToggled()

Fields

leftClick

Function that is executed when the left mouse button is clicked

The function has one argument

The first argument is this action itself

Examples:

-- pingless example
function myAction.leftClick()
log("Left click")
end
-- pinged example
function pings.example()
log("Left click")
end

myAction.leftClick = pings.example

rightClick

Function that is executed when the right mouse button is clicked

The function has one argument

The first argument is this action itself

Example:

function myAction.rightClick()
log("Right click")
end

toggle

Function that is executed when the Action is toggled

The function has two arguments

The first argument is toggle state of this action

The second argument is this action itself

Example:

function myAction.toggle(bool)
log("The toggle is " .. tostring(bool))
end

untoggle

Function that is executed when the Action is untoggled

The function has two arguments

The first argument is toggle state of this action

The second argument is this action itself

Example:

function myAction.untoggle(bool)
log("The toggle is " .. tostring(bool))
end

scroll

Function that is executed when the mouse is scrolled

The function has two arguments

The first argument is mouse wheel direction

The second argument is this action itself

Example:

function myAction.scroll(dir)
log(dir)
if dir > 0 then
log("Scrolling up")
else
log("Scrolling down")
end
end