Skip to main content

Action

An action in the Action Wheel. Actions are either interacted with by clicking or scrolling. Actions can either run an action on interaction or when toggled.

For this entire page assume:

local myPage = action_wheel:newPage()
action_wheel:setPage(myPage)

Action Events

Technically they are "callbacks" and not "events" as you can only assign a single function, but eh. It's common practice to pass pings to these functions since interacting with the action_wheel is not synced between clients. Checkout the setOnToggle function to see an example.


setOnLeftClick(leftFunction: LeftFunction): Action

Sets the function that is executed when the left mouse button is clicked. Figura passes the Action itself as the first parameter.

Parameters

NameTypeDescription
leftFunctionLeftFunctonThe function that runs when you left click the Action

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setOnLeftClick(function()
print('I left clicked this button!')
end)

leftClick

The field that holds the callback for when the left mouse button is clicked on the Action. The type of this field is fun(action: Action). This type will be referred to as LeftFunction elsewhere in the wiki.

Parameters

NameTypeDescription
actionActionThe action the callback was called by

setOnRightClick(rightFunction: RightFunction): Action

Sets the function that is executed when the right mouse button is clicked. Figura passes the Action itself as the first parameter.

Parameters

NameTypeDescription
rightFunctionRightFunctonThe function that runs when you right click the Action

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setOnRightClick(function()
print('I right clicked this button!')
end)

rightClick

The field that holds the callback for when the right mouse button is clicked on the Action. The type of this field is fun(action: Action). This type will be referred to as RightFunction elsewhere in the wiki.

Parameters

NameTypeDescription
actionActionThe action the callback was called by

setOnToggle(toggleFunction: ToggleFunction): Action

When the Action is assigned a function to the toggle field, it becomes a Toggle Action. Figura passes the Toggle Action's internal state variable as the first parameter, and the Action itself as the second.

Parameters

NameTypeDescription
toggleFunctionToggleFunctionThe function that runs when you toggle the Action

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

function pings.setVisible(state)
models:setVisible(state)
end

myPage:newAction()
:title("disabled")
:toggleTitle("enabled")
:item("red_wool")
:toggleItem("green_wool")
:setOnToggle(pings.setVisible)

toggle

The field that holds the callback for when the Action is toggled. The type of this field is fun(state: boolean, action: Action). This type will be referred to as ToggleFunction elsewhere in the wiki.

Parameters

NameTypeDescription
statebooleanWhether the action was toggled on or off
actionActionThe action the callback was called by

setOnUntoggle(untoggleFunction: UntoggleFunction): Action

Unlike Toggle which gets executed when the Action is toggled on or off, UnToggle only gets executed when the Action is toggled off. Figura passes the Toggle Action's internal state variable as the first parameter (which is always false due to the nature of UnToggle), and the Action itself as the second.

info

setOnUntoggle is redundant because setOnToggle will also work when the action is untoggled if there is no OnUntoggle function set.

Parameters

NameTypeDescription
toggleFunctionUntoggleFunctionThe function that runs when you untoggle the Action

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setOnToggle(function(bool)
print('This is always true: ', .. bool)
end)
:setOnUntoggle(function(bool)
print('This is always false: ' .. bool)
end)

Untoggle

The field that holds the callback for when the Action is untoggled. The type of this field is fun(state: boolean, action: Action). This type will be referred to as UntoggleFunction elsewhere in the wiki.

Parameters

NameTypeDescription
statebooleanWhether the action was toggled on or off. In this case, it is always false
actionActionThe action the callback was called by

setOnScroll(onScroll: ScrollFunction): Action

This will execute when the mouse wheel scrolls while hovering over the Action. The first parameter is the direction the mouse scrolled (1 for scroll up, -1 for scroll down. Can be more than 1 for non-standard mouse wheels). The second paremeter is the Action itself.

Parameters

NameTypeDescription
toggleFunctionScrollFunctionThe function that runs when you scroll on the Action

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

local current = 0

myPage:newAction()
:title('Current: ', current)
:setOnScroll(function(dir, self)
print("Scrolled in this direction: " .. dir)
current = current + dir
self:title('Current: ', current)
end)

scroll

The field that holds the callback for when the Action is scrolled. The type of this field is fun(dir: number, action: Action). This type will be referred to as ScrollFunction elsewhere in the wiki.

Parameters

NameTypeDescription
dirnumberThe direction the scrollwheel was moved. Positive for up and negative for down.
actionActionThe action the callback was called by

Appearance

Functions to modify how your Action looks.


setTitle(title: string): Action

Sets the title of the Action.

Parameters

NameTypeDescription
titlestringThe title that displays when you hover over the Action

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setTitle('Click me!')

getTitle(): string

Gets the Action's title.

Returns

NameTypeDescription
titlestringThe Action's current title

Example:

local myAction = myPage:newAction()
:setTitle('Click me!')

print(myAction:getTitle())

setItem(item: ItemStack): Action

Sets an item to display on the Acton.

Parameters

NameTypeDescription
itemItemStackThe item to set the Action's icon to

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setItem('minecraft:stone')

setColor(color: Vector3): Action

Sets the color of the Action. Takes a Vector3 of rgb values or a number per value. The rgb values are between 0 and 1.

Parameters

NameTypeDescription
colorVector3A vector of rgb values

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setColor(255 / 255, 192 / 155, 203 / 255)

getColor(): Vector3

Gets the Action's color. Returns a Vector3.

Returns

NameTypeDescription
colorVector3A vector of rgb values

Example:

myPage:newAction()
:setColor(255 / 255, 192 / 155, 203 / 255)

print(myAction:getColor())

setTexture(texture: Texture, U: number?, V: number?, width: number?, height: number?, scale: number?): Action

Sets the texture of the Action. All parameters other than Texture are optional.

Parameters

NameTypeDescriptionDefault
textureTextureThe item to set the Action's icon to
UnumberThe U value of the UV0
VnumberThe V value of the UV0
widthnumberThe width to set the texture totexture's width
heightnumberThe height to set the texture totexture's height
scalenumberThe scale to set the texture to1

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

-- basic
myPage:newAction()
:setTexture(textures['myTexture'])

-- advanced
myPage:newAction()
:setTexture(textures['myTexture'], 16, 32, nil, nil, 2)


setHoverColor(color: Vector3): Action

Sets the color of the Action when it's being hovered. Takes a Vector3 of rgb values or a number per value. The rgb values are between 0 and 1.

Parameters

NameTypeDescription
colorVector3A vector of rgb values

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setHoverColor(255 / 255, 192 / 155, 203 / 255)

getHoverColor(): Vector3

Gets the Action's hover color. Returns a Vector3.

Returns

NameTypeDescription
colorVector3A vector of rgb values

Example:

myPage:newAction()
:setHoverColor(255 / 255, 192 / 155, 203 / 255)

print(myAction:getHoverColor())

setHoverTexture(texture: Texture, U: number?, V: number?, width: number?, height: number?, scale: number?): Action

Sets the texture of the Action when it's hovered. All parameters other than Texture are optional.

Parameters

NameTypeDescriptionDefault
textureTextureThe item to set the Action's icon to
UnumberThe U value of the UV0
VnumberThe V value of the UV0
widthnumberThe width to set the texture totexture's width
heightnumberThe height to set the texture totexture's height
scalenumberThe scale to set the texture to1

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

-- basic
myPage:newAction()
:setHoverTexture(textures['myTexture'])

-- advanced
myPage:newAction()
:setHoverTexture(textures['myTexture'], 16, 32, nil, nil, 2)


Toggle Specific

When the Action is assigned a function to the toggle field, it becomes a Toggle Action. These functions apply to those Actions.


setToggleTitle(title: string): Action

Sets the title of the Action when toggled.

Parameters

NameTypeDescription
titlestringThe title that displays when you hover over the Action while it is toggled

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setTitle('Sit')
:setOnToggle(pings.sit)
:setToggleTitle('Stand')

getToggleTitle(): string

Gets the Action's title when toggled.

Returns

NameTypeDescription
titlestringThe Action's current title while toggled

Example:

myPage:newAction()
:setToggleTitle('Stand')

print(myAction:getToggleTitle())

setToggleItem(item: ItemStack): Action

Sets an item to display on the Acton when toggled.

Parameters

NameTypeDescription
itemItemStackThe item to set the Action's icon to while toggled

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setTitle('Sit')
:setItem('spruce_stairs')
:setOnToggle(pings.sit)
:setToggleTitle('Stand')
:setToggleItem('armor_stand')

setToggleColor(color: Vector3): Action

Sets the color of the Action when toggled. Takes a Vector3 of rgb values or a number per value. The rgb values are between 0 and 1.

Parameters

NameTypeDescription
colorVector3A vector of rgb values

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

myPage:newAction()
:setColor(255 / 255, 192 / 255, 203 / 255)
:setToggleColor(0, 128 / 255, 128 / 255)

getToggleColor(): Vector3

Gets the Action's color when toggled. Returns a Vector3.

Returns

NameTypeDescription
colorVector3A vector of rgb values

Example:

myPage:newAction()
:setToggleColor(255 / 255, 192 / 155, 203 / 255)

print(myAction:getToggleColor())

setToggleTexture(texture: Texture, U: number?, V: number?, width: number?, height: number?, scale: number?): Action

Sets the texture of the Action when toggled. All parameters other than Texture are optional.

Parameters

NameTypeDescriptionDefault
textureTextureThe item to set the Action's icon to
UnumberThe U value of the UV0
VnumberThe V value of the UV0
widthnumberThe width to set the texture totexture's width
heightnumberThe height to set the texture totexture's height
scalenumberThe scale to set the texture to1

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

-- basic
myPage:newAction()
:setTexture(textures['myTexture'])
:setToggleTexture(textures['myToggleTexture'])

-- advanced
myPage:newAction()
:setTexture(textures['myTexture'], 0, 32, nil, nil, 2)
:setToggleTexture(textures['myTexture'], 16, 32, nil, nil, 2)


setToggled(state: boolean): Action

Sets the toggle state of the Action.

Parameters

NameTypeDescription
statebooleanChanges the current state of the toggle

Returns

NameTypeDescription
actionActionThe Action you called this function on to allow for chaining

Example:

local myAction = myPage:newAction()
:setOnToggle(function(b) print('Toggled: ' .. b) end)

local t = 0

function events.tick()
if t % 20 == 0 then
local wasToggled = myAction:isToggled()
myAction:setToggled(not wasToggled)
end
t = t + 1
end

isToggled(): boolean

Checks if the action is toggled or not. Returns a boolean.

Returns

NameTypeDescription
statebooleanWhether or not the Action is toggled

Example:

local myAction = myPage:newAction()
:setOnToggle(function(b) print('Toggled: ' .. b) end)

local t = 0

function events.tick()
if t % 20 == 0 then
local wasToggled = myAction:isToggled()
myAction:setToggled(not wasToggled)
end
t = t + 1
end