Skip to main content

Quick Reference

Common patterns for Hexis scripting.


Main Loop Pattern

while hexis.running() do
-- logic
hexis.sleep(100)
end

Check and Equip Item

if hexis.player.hotbar_contains("scythe") then
hexis.actions.equip({name = "scythe"})
end

Combat Loop

hexis.combat.start({targets = {"Enderman"}, style = "ranged"})
-- Later...
hexis.combat.stop()

hexis.navigate.to({x = 100, y = 64, z = 200})

GUI Interaction

hexis.gui.safe_mode()
hexis.gui.open()
hexis.sleep(300)
hexis.gui.click_item({name = "Confirm"})
hexis.gui.close()

Event Listener

hexis.events.on("sound", "experience_orb", function()
kills = kills + 1
hexis.hud.set_var("kills", kills)
end)

HUD Setup

hexis.hud.create({
title = "My Script",
elements = {
{type = "stat", label = "Kills", value = "{kills}"},
{type = "stat", label = "Time", value = "{elapsed_time}"},
}
})

hexis.hud.set_var("kills", 0)
hexis.hud.show()

Mining Loop

hexis.mining.start_loop({
id = "farming",
max_distance = 50,
aim_speed = 2.5,
chain_mining = true
})
-- Later...
hexis.mining.stop_loop()

Route Loading

local route = hexis.routes.load("foraging/park/Park_Foraging")
if route then
hexis.log.info("Loaded: " .. route.name)
hexis.log.info("Blocks: " .. route.block_count)
end

Error Handling

local success, err = pcall(function()
hexis.navigate.to({x = 0, y = 0, z = 0})
end)

if not success then
hexis.log.error("Navigation failed: " .. tostring(err))
end

Logging

hexis.log.info("Information message")
hexis.log.debug("Debug message") -- Only in debug mode
hexis.log.warn("Warning message")
hexis.log.error("Error message")

Timer

hexis.timer.start()
-- ... do stuff ...
hexis.log.info("Elapsed: " .. hexis.timer.formatted())
hexis.timer.stop()

Format Numbers

hexis.format.duration(123)      -- "2m 3s"
hexis.format.number(15320) -- "15.3k"
hexis.format.coins(15320) -- "15.3k"