Examples

Spammer with HUD text

Settings, tick logic and 2D rendering in one module.

local module = ui.category("scripts"):module("code", "Lua Example")

local interval = module:number("Interval", 40, 5, 200, 1, "t")
local message = module:string("Message", "Hello from Lua!")
local mode = module:selection("Mode", nil, { "Client", "Chat" })
local hud = module:boolean("HUD text", true)
local color = module:color("Color", 0xFF4FF2A6)

local ticks = 0

module:callback("enable", function()
    ticks = 0
end)

module:event("tick", function()
    ticks = ticks + 1
    if ticks % interval:get() == 0 then
        if mode:get() == "Chat" then
            client.say_chat(message:get())
        else
            client.print_chat(message:get())
        end
    end
end)

module:event("render_2d", function(render)
    if not hud:get() or not local_player.entity() then return end
    local label = message:get() .. "  |  " .. client.fps() .. " fps"
    local w = render.text_width(label, 9) + 16
    render.rect(8, render.height() - 40, w, 22, 0x90101010, 7)
    render.text(label, 16, render.height() - 34, 9, color:get())
end)

2D ESP with JIT compilation

A full configurable ESP: target filtering, Box/Corner styles, health bar, names and distance. Data is collected once per tick; rendering only projects and draws.

-- @jit
local module = ui.category("visuals"):module("draw-square", "Lua ESP 2D")

local targets = module:multi_selection(
    "Targets",
    { "Players" },
    { "Players", "Mobs", "Items", "Other" }
)
local style = module:selection("Style", nil, { "Box", "Corner" })
local color = module:color("Color", 0xFF4FF2A6)
local thickness = module:number("Thickness", 1, 1, 5, 1)
local fill = module:boolean("Fill", false)
local names = module:boolean("Names", true)
local healthBar = module:boolean("Health bar", true)
local distanceTag = module:boolean("Distance", false)
local maxDistance = module:number("Max distance", 128, 16, 512, 8, "m")

local tracked = {}

local function classify(e)
    if e.type == "minecraft:player" then
        return "Players"
    elseif e.type == "minecraft:item" then
        return "Items"
    elseif e.health then
        return "Mobs"
    end
    return "Other"
end

module:callback("enable", function()
    tracked = {}
end)

module:callback("disable", function()
    tracked = {}
end)

module:event("tick", function()
    local selected = {}
    for _, t in ipairs(targets:get()) do
        selected[t] = true
    end
    local limit = maxDistance:get()
    local list = {}
    for _, e in ipairs(world.entities()) do
        if not e.is_self and e.distance <= limit and selected[classify(e)] then
            list[#list + 1] = e
        end
    end
    tracked = list
end)

local function healthColor(frac)
    local r = math.floor(255 * (1 - frac))
    local g = math.floor(255 * frac)
    return 0xFF000000 + r * 0x10000 + g * 0x100
end

local function drawCorners(render, x, y, w, h, argb, stroke)
    local len = math.min(w, h) * 0.3
    render.line(x, y, x + len, y, argb, stroke)
    render.line(x, y, x, y + len, argb, stroke)
    render.line(x + w - len, y, x + w, y, argb, stroke)
    render.line(x + w, y, x + w, y + len, argb, stroke)
    render.line(x, y + h - len, x, y + h, argb, stroke)
    render.line(x, y + h, x + len, y + h, argb, stroke)
    render.line(x + w, y + h - len, x + w, y + h, argb, stroke)
    render.line(x + w - len, y + h, x + w, y + h, argb, stroke)
end

module:event("render_2d", function(render)
    local count = #tracked
    if count == 0 or not world.exists() then return end

    local argb = color:get()
    local stroke = thickness:get()
    local corner = style:get() == "Corner"
    local drawFill = fill:get()
    local drawNames = names:get()
    local drawHealth = healthBar:get()
    local drawDistance = distanceTag:get()
    local fillColor = (argb % 0x1000000) + 0x28000000

    for i = 1, count do
        local e = tracked[i]
        local x, y, w, h = projection.entity_box(e.id)
        if x then
            if drawFill then
                render.rect(x, y, w, h, fillColor)
            end
            if corner then
                drawCorners(render, x, y, w, h, argb, stroke)
            else
                render.outline(x - 1, y - 1, w + 2, h + 2, 0x80000000, 0, stroke + 2)
                render.outline(x, y, w, h, argb, 0, stroke)
            end
            if drawHealth and e.health then
                local frac = e.health / e.max_health
                if frac > 1 then frac = 1 end
                render.rect(x - 5, y, 2, h, 0xA0101010)
                render.rect(x - 5, y + h * (1 - frac), 2, h * frac, healthColor(frac))
            end
            if drawNames then
                local tw = render.text_width(e.name, 9)
                render.text(e.name, x + (w - tw) / 2, y - 13, 9, argb)
            end
            if drawDistance then
                local tag = string.format("%dm", math.floor(e.distance + 0.5))
                local tw = render.text_width(tag, 8)
                render.text(tag, x + (w - tw) / 2, y + h + 3, 8, 0xFFFFFFFF)
            end
        end
    end
end)

Auto totem via services

local module = ui.category("combat"):module("shield-heart", "Lua Auto Totem")

module:event("tick", function()
    if inventory.item(45).id ~= "minecraft:totem_of_undying" then
        local totem = inventory.find("minecraft:totem_of_undying")
        if totem then inventory.swap(totem, 45) end
    end
end)