Skip to main content

Host

The host API is accessed through the host global. Like so: host:isFlying()

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

Example:

host:isHost()

Player Data


isJumping()

Checks if the jump key is being pressed.

Example:

host:isJumping()

isFlying()

Checks if the player is currently creative flying

Example:

host:isFlying()

isContainerOpen()

Checks if the host has a container screen opened

Example:

host:isContainerOpen()

getAir()

Gets the remaining amount of air of the player. From 300 to -19, whenever you take damage from drowning it sets back to 0. Water breathing freezes the value when underwater. Respiration slows down how quickly the number goes down.

Example:

host:getAir()

getSlot(number or string)

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

For the numerical id, 0-8 are the hotbar, 9-35 are the rest of the inventory starting from the top left slot, 99 is the offhand, and 100-103 are the armor slots from the boots to the helmet. player:getItem() is a better alternative for getting equipment slots.

Example:

host:getSlot(0)

setSlot(slot, item)

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

Example:

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

getScreenSlot(slot)

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

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

Example:

host:getScreenSlotCount()

getScreen()

Gets the class name of the screen the player is currently on. Class names are slightly obfuscated by Minecraft's code and will return a string ending in numbers that are the class' id. A list of class ids can be found in GS' VSCode docs, or you can use a log to get the name of the screen you're accessing.

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

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. To access a sub table index the effect table with the sub-table's name. Re the example below: effect.name

Example:

for _, effect in pairs(host:getStatusEffects()) do
logTable(effect)
end

getAttackCharge()

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

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

Example:

host:getAttackCharge()

getReachDistance()

Returns the current reach distance of the player

Example:

host:getReachDistance()

getPickBlock()

Returns the current targeted block set by the client

Returns a vararg of the block, the hit position and the block face the hit collided

player:getTargetedBlock() can be used as a synced alternative to this function.

Example:

host:getPickBlock()

getPickEntity()

Returns the current targeted entity set by the client

player:getTargetedEntity() can be used as a synced alternative to this function.

Example:

host:getPickEntity()

Chat


isChatOpen()

Checks if the host has the chat screen opened

Example:

host:isChatOpen()

sendChatCommand(string)

Sends the given command in the chat

caution

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

Example:

host:sendChatCommand("kill @a")

sendChatMessage(string)

Sends the given message in the chat

caution

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

Example:

host:sendChatMessage("Hello World")

setChatMessage(number, string, Vector3)

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

The third arg is the background color of the message

Example:

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

getChatMessage(number)

Returns a table with information about a chat message

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

Example:

host:getChatMessage(1)

appendChatHistory(string)

Appends the message on the recent chat history

Example:

host:appendChatHistory("Hello World")

setChatText(string)

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

caution

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

Example:

host:setChatText("Hello World")

getChatText()

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

Example:

host:getChatText("Hello World")

setChatColor(Vector3)

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

Example:

host:setChatColor(0, 0, 1)

getChatColor()

Gets the chat window text color

Example:

host:getChatColor()

isChatVerified()

Presumably gets if the messages being sent are verified by the Minecraft server (speculation)

Example:

host:isChatVerified()

Other


swingArm(boolean)

Animates swinging the player's arm

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

Example:

host:swingArm()

setTitle(string)

Sets the current title to the given text

The text is given as json

Example:

host:setTitle("Hello World")

setSubtitle(string)

Sets the current subtitle to the given text The text is given as json

Example:

host:setSubtitle("Hello World")

setActionbar(string, boolean)

Sets the action bar message to the given text

The boolean parameter defaults to false and sets if the text will be animated

Example:

host:setActionbar("Hello World")

setTitleTimes(Vector3)

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

The inputs for the Vector3 are ordered like-so: (fadeInTime, stayTime, fadeOutTime)

Example:

host:setTitleTimes(5, 5, 5)

clearTitle()

Clears the current title from the GUI

Example:

host:clearTitle()

setUnlockCursor(boolean)

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

Example:

host:setUnlockCursor(true)

isCursorUnlocked()

Checks if the cursor is currently unlocked

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

Example:

host:isCursorUnlocked()

screenshot()

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

Example:

host:screenshot()

setClipboard(string)

Sets the clipboard text

Example:

host:setClipboard("Hello World")

getClipboard()

Gets the text from the clipboard

Example:

host:getClipboard()

isAvatarUploaded()

Checks if this avatar is currently uploaded

Example:

host:isAvatarUploaded()