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
| Name | Type | Description |
|---|---|---|
| leftFunction | LeftFuncton | The function that runs when you left click the Action |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| rightFunction | RightFuncton | The function that runs when you right click the Action |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| toggleFunction | ToggleFunction | The function that runs when you toggle the Action |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| state | boolean | Whether the action was toggled on or off |
| action | Action | The 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.
setOnUntoggle is redundant because setOnToggle will also work when the action is untoggled if there is no OnUntoggle function set.
Parameters
| Name | Type | Description |
|---|---|---|
| toggleFunction | UntoggleFunction | The function that runs when you untoggle the Action |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| state | boolean | Whether the action was toggled on or off. In this case, it is always false |
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| toggleFunction | ScrollFunction | The function that runs when you scroll on the Action |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| dir | number | The direction the scrollwheel was moved. Positive for up and negative for down. |
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| title | string | The title that displays when you hover over the Action |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The Action you called this function on to allow for chaining |
Example:
myPage:newAction()
:setTitle('Click me!')
getTitle(): string
Gets the Action's title.
Returns
| Name | Type | Description |
|---|---|---|
| title | string | The 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
| Name | Type | Description |
|---|---|---|
| item | ItemStack | The item to set the Action's icon to |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| color | Vector3 | A vector of rgb values |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| color | Vector3 | A 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
| Name | Type | Description | Default |
|---|---|---|---|
| texture | Texture | The item to set the Action's icon to | |
| U | number | The U value of the UV | 0 |
| V | number | The V value of the UV | 0 |
| width | number | The width to set the texture to | texture's width |
| height | number | The height to set the texture to | texture's height |
| scale | number | The scale to set the texture to | 1 |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| color | Vector3 | A vector of rgb values |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| color | Vector3 | A 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
| Name | Type | Description | Default |
|---|---|---|---|
| texture | Texture | The item to set the Action's icon to | |
| U | number | The U value of the UV | 0 |
| V | number | The V value of the UV | 0 |
| width | number | The width to set the texture to | texture's width |
| height | number | The height to set the texture to | texture's height |
| scale | number | The scale to set the texture to | 1 |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| title | string | The title that displays when you hover over the Action while it is toggled |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| title | string | The 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
| Name | Type | Description |
|---|---|---|
| item | ItemStack | The item to set the Action's icon to while toggled |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| color | Vector3 | A vector of rgb values |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| color | Vector3 | A 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
| Name | Type | Description | Default |
|---|---|---|---|
| texture | Texture | The item to set the Action's icon to | |
| U | number | The U value of the UV | 0 |
| V | number | The V value of the UV | 0 |
| width | number | The width to set the texture to | texture's width |
| height | number | The height to set the texture to | texture's height |
| scale | number | The scale to set the texture to | 1 |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| state | boolean | Changes the current state of the toggle |
Returns
| Name | Type | Description |
|---|---|---|
| action | Action | The 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
| Name | Type | Description |
|---|---|---|
| state | boolean | Whether 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