Skip to main content

Host

A global API dedicated to specifically the host of the avatar

warning

This page is a WIP. It contains all the information in Figura's documentation but we're working on adding more helpful descriptions.

For other viewers, these do nothing

Functions in the host API aren't synced, meaning to be useful in multiplayer their information will need to be synced via pings


isHost()

Returns true if this instance of the script is running on host

isHost()

Returns:

TypeDescription
Boolean-

Example:

host:isHost()

Player Data

isContainerOpen()

Checks if the host has a container screen opened

isContainerOpen()

Returns:

TypeDescription
Boolean-

Example:

host:isContainerOpen()

isFlying()

Checks if the player is currently flying

isFlying()

Returns:

TypeDescription
Boolean-

Example:

host:isFlying()

isJumping()

Checks if the player is jumping

Note this is only true during the first tick the player started jumping

isJumping()

Returns:

TypeDescription
Boolean-

Example:

host:isJumping()

getAir()

Gets the remaining amount of air of the player

getAir()

Returns:

TypeDescription
Integer-

Example:

host:getAir()

setSlot()

Sets a slot with an ItemStack

The slot is either their numerical id (0 indexed) or the slot string, as used in the /item command

Slot -1 uses the first available slot

Only runs for creative mode

setSlot(slot)

Parameters:

NameTypeDescriptionDefault
slotString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setSlot(0, "apple")
-- setSlot also accepts an ItemStack retrieved from an actual item or world:newItem()

getSlot()

Gets an ItemStack for the item in the given slot

The slot is either their numerical id (0 indexed) or the slot string, as used in the /item command

getSlot(slot)

Parameters:

NameTypeDescriptionDefault
slotString--

Returns:

TypeDescription
ItemStack-

Example:

host:getSlot(0)

getScreenSlot()

Gets the item in a screen slot

The slot is either their numerical id (0 indexed) or the slot string, as used in the /item command

If the player is not currently in a screen, the screen has no slots, or the slot index is greater than the maximum, returns nil

getScreenSlot(slot)

Parameters:

NameTypeDescriptionDefault
slotString--

Returns:

TypeDescription
ItemStack-

Example:

host:getScreenSlot(0)

getScreenSlotCount()

Gets the number of slots in the screen the player is currently in

If the player is not currently in a screen or the screen has no slots, returns nil

getScreenSlotCount()

Returns:

TypeDescription
Integer-

Example:

host:getScreenSlotCount()

getScreen()

Gets the class name of the screen the player is currently on

If the player is not currently in a screen, returns nil

getScreen()

Returns:

TypeDescription
String-

Example:

host:getScreen()

getStatusEffects()

Returns a table of all of the player's status effects

The table contains sub-tables, each of which contains the name, amplifier, duration, and particle visibility of each status effect

getStatusEffects()

Returns:

TypeDescription
Table-

Example:

for _, effect in pairs(host:getStatusEffects()) do
logTable(effect) -- prints all the effect information into chat
log(effect.name) -- gets the effect's name and prints it into chat
end

getAttackCharge()

Returns a fraction (0 to 1) of the charge of the player attack

If less than 1, every attack will result in a weak attack

getAttackCharge()

Returns:

TypeDescription
Number-

Example:

host:getAttackCharge()

getReachDistance()

Returns the current reach distance of the player

getReachDistance()

Returns:

TypeDescription
Number-

Example:

host:getReachDistance()

getPickBlock()

Returns the current targeted block set by the client

Returns the block, the hit position, and the targeted block face as three separate values

getPickBlock()

Returns:

TypeDescription
BlockStateTargeted block
Vector3Hit position
StringTargeted block face

Example:

local block, hitPos, side = host:getPickBlock()

getPickEntity()

Returns the currently targeted entity set by the client

getPickEntity()

Returns:

TypeDescription
EntityAPI-

Example:

host:getPickEntity()

Chat

isChatOpen()

Checks if the host has the chat screen opened

isChatOpen()

Returns:

TypeDescription
Boolean-

Example:

host:isChatOpen()

isChatVerified()

figura.docs.host.is_chat_verified

isChatVerified()

Returns:

TypeDescription
Boolean-

Example:

host:isChatVerified()

sendChatCommand()

caution

In order to use this function you must turn the Chat Messages setting on in Figura's settings

Sends the given command in the chat

sendChatCommand(command)

Parameters:

NameTypeDescriptionDefault
commandString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:sendChatCommand("kill @a")

sendChatMessage()

caution

In order to you this function you must turn the Chat Messages setting on in Figura's settings

Sends the given message in the chat

sendChatMessage(message)

Parameters:

NameTypeDescriptionDefault
messageString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:sendChatMessage("Hello World")

setChatColor()

Aliases: chatColor()

Sets the color of the text that is currently being typed into the chat window

setChatColor(color)

Parameters:

NameTypeDescriptionDefault
colorVector3--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setChatColor(0, 0, 1)

getChatColor()

Gets the chat window text color

getChatColor()

Returns:

TypeDescription
Integer-

Example:

host:getChatColor()

setChatMessage()

Modifies a chat message with the given text

Takes an index, were 1 means the last message on chat

Setting the message to nil will effectively remove it from the chat

setChatMessage(index)

Parameters:

NameTypeDescriptionDefault
indexInteger--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setChatMessage(1, "Hi?", vec(1, 0, 0))

getChatMessage()

Returns a table with information about a chat message

Takes an index, where 1 means the last message on chat

getChatMessage(index)

Parameters:

NameTypeDescriptionDefault
indexInteger--

Returns:

TypeDescription
Table-

Example:

host:getChatMessage(1)

setChatText()

Aliases: chatText()

caution

In order to use this function you must turn the Chat Messages setting on in Figura's settings

Sets the text currently being typed in the chat window to the given string

setChatText(text)

Parameters:

NameTypeDescriptionDefault
textString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setChatText("Hello World")

getChatText()

Gets the text that is currently being typed into the chat window

getChatText()

Returns:

TypeDescription
String-

Example:

host:getChatText() == "Hello World"

appendChatHistory()

Appends the message on the recent chat history

appendChatHistory(message)

Parameters:

NameTypeDescriptionDefault
messageString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:appendChatHistory("Hello World")

Other

setActionbar()

Aliases: actionbar()

Sets the action bar message to the given text

The boolean parameter defaults to false

setActionbar(text)

Parameters:

NameTypeDescriptionDefault
textString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setActionbar("Hello World")

setClipboard()

Aliases: clipboard()

Sets the clipboard text

setClipboard(text)

Parameters:

NameTypeDescriptionDefault
textString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setClipboard("Hello World")

getClipboard()

Gets the text from the clipboard

getClipboard()

Returns:

TypeDescription
String-

Example:

host:getClipboard()

setSubtitle()

Aliases: subtitle()

Sets the current subtitle to the given text

The text is given as a JSON string

setSubtitle(text)

Parameters:

NameTypeDescriptionDefault
textString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setSubtitle("Hello World")

setTitle()

Aliases: title()

Sets the current title to the given text

The text is given as json

setTitle(text)

Parameters:

NameTypeDescriptionDefault
textString--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setTitle("Hello World")

setTitleTimes()

Aliases: titleTimes()

Sets the duration of the title on the screen, also its fade-in and fade-out durations

setTitleTimes(timesData)

Parameters:

NameTypeDescriptionDefault
timesDataVector3--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setTitleTimes(5, 5, 5)

setUnlockCursor()

Toggles locking of your cursor, letting you move it freely on the screen instead of it controlling your player's rotation

setUnlockCursor(boolean)

Parameters:

NameTypeDescriptionDefault
booleanBoolean--

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:setUnlockCursor(true)

clearTitle()

Clears the current title from the GUI

clearTitle()

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:clearTitle()

isAvatarUploaded()

Checks if this avatar is currently uploaded

isAvatarUploaded()

Returns:

TypeDescription
Boolean-

Example:

host:isAvatarUploaded()

isCursorUnlocked()

Checks if the cursor is currently unlocked

Only responds to your own changes in your script, not anything done by Minecraft itself

isCursorUnlocked()

Returns:

TypeDescription
Boolean-

Example:

host:isCursorUnlocked()

screenshot()

Takes a screenshot from the current screen and returns a Texture of it

screenshot(name)

Parameters:

NameTypeDescriptionDefault
nameString--

Returns:

TypeDescription
Texture-

Example:

host:screenshot()

swingArm()

Animates swinging the player's arm

If the boolean is true, then the offhand is the one that swings

swingArm()

Returns:

TypeDescription
HostAPIReturns self for chaining

Example:

host:swingArm()

Fields

unlockCursor

Setting this value to true will unlock your cursor, letting you move it freely on the screen instead of it controlling your player's rotation

See setUnlockCursor for an example of how to set it.