> ## Documentation Index
> Fetch the complete documentation index at: https://docs.selvut.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Global API Reference

> Quick reference for the active script globals.

## Script

| Function                               | Description                                        |
| -------------------------------------- | -------------------------------------------------- |
| `Script.meta(object)`                  | Set name/category/description                      |
| `Script.name(name)`                    | Set module name                                    |
| `Script.category(category)`            | Set module category                                |
| `Script.description(text)`             | Set module description                             |
| `Script.on(event, fn)`                 | Register callback                                  |
| `Script.thread(fn)`                    | Start function on enable in a script worker thread |
| `Script.cleanup(fn)` / `onCleanup(fn)` | Register cleanup code for disable/unload           |
| `Script.command(name, options?, fn)`   | Register command                                   |
| `Script.setTimeout(fn, delayMs)`       | Run once later; callback receives the timer id     |
| `Script.setInterval(fn, intervalMs)`   | Run repeatedly; callback receives the timer id     |
| `Script.clearTimer(id)`                | Cancel timer                                       |
| `Script.clearInterval(id)`             | Cancel interval                                    |
| `Script.stopAllTasks()`                | Cancel all script timers                           |
| `Script.throttle(key?, intervalMs)`    | Return true only once per interval                 |
| `Script.enabled()`                     | Whether this script is running                     |

## Client And Chat

| Function                                            | Description                               |
| --------------------------------------------------- | ----------------------------------------- |
| `Client.notify(text)`                               | Show notification                         |
| `Client.log(text)` / `Chat.log(text)`               | Print client-side info                    |
| `Client.command(command)` / `Chat.command(command)` | Run client command or send server command |
| `Chat.send(text)`                                   | Send chat message                         |
| `Client.screenName()` / `screenClass()`             | Current screen                            |
| `Client.isInGame()`                                 | Player and world are loaded               |
| `Client.playerName()`                               | Local player name                         |
| `Client.fps()` / `ping()` / `tps()`                 | Client/server metrics                     |
| `Client.tickMultiplier()`                           | Current local tick multiplier             |
| `Client.setTickMultiplier(multiplier)`              | Set this script's tick multiplier         |
| `Client.clearTickMultiplier()`                      | Clear this script's tick multiplier       |
| `Client.displaySize()`                              | `[guiWidth, guiHeight, guiScale]`         |
| `Client.screenWidth()` / `screenHeight()`           | GUI-scaled size                           |
| `Client.windowWidth()` / `windowHeight()`           | Raw framebuffer size                      |
| `Client.guiScale()`                                 | GUI scale                                 |
| `Client.mouseX()` / `mouseY()`                      | GUI-scaled mouse position                 |
| `Client.inFocus()`                                  | Whether the game window is focused        |
| `Client.isSinglePlayer()`                           | Whether an integrated server is active    |
| `Client.isCreative()` / `isSpectator()`             | Local player mode flags                   |
| `Client.allowFlying()` / `isFlying()`               | Local player ability flags                |
| `Client.actionBar()` / `title()` / `subtitle()`     | Last seen overlay/title text              |
| `Client.tabHeader()` / `tabFooter()`                | Last seen tab-list header/footer          |
| `Client.serverAddress()` / `serverName()`           | Current server info                       |
| `Client.module(name)` / `modules()`                 | Module info                               |
| `Client.isModuleEnabled(name)`                      | Toggle module state                       |
| `Client.setModuleEnabled(name, state)`              | Set toggle module state                   |
| `Client.toggleModule(name)`                         | Toggle a module                           |
| `Client.raw()`                                      | Raw Minecraft client                      |

## Utility APIs

| API           | Purpose                                                                      |
| ------------- | ---------------------------------------------------------------------------- |
| `Setting`     | Script module settings                                                       |
| `Color`       | `rgb`, `rgba`, and `argb` color helpers                                      |
| `Random`      | Random numbers, booleans, and array choices                                  |
| `Vec3`        | Vector construction and distance                                             |
| `Anim`        | Clamp, lerp, easing, and pulse helpers                                       |
| `Render`      | 2D, world overlay, item/entity GUI, projection, and scissor helpers          |
| `Texture`     | Script-owned image loading for `Render.image`                                |
| `Shader`      | External/runtime shader and entity target helpers                            |
| `Sound`       | Play Selvut's custom sound files                                             |
| `Hud`         | Script-owned HUD element creation                                            |
| `Input`       | Keyboard, mouse, and movement state                                          |
| `Inventory`   | Container and hotbar inspection/click helpers                                |
| `KeyBind`     | Key binding press/release helpers                                            |
| `Rotation`    | Script-owned silent rotation requests                                        |
| `Interaction` | Attack, use, raytrace, entity, and block interaction helpers                 |
| `Async`       | Worker, timer, polling, and HTTP helpers with cancellable handles            |
| `Pathfinder`  | Path finding and movement-follow helpers                                     |
| `Friend`      | Friend manager access                                                        |
| `Packet`      | Typed send helpers plus raw packet send/info                                 |
| `Time`        | `now`, `nanos`, and sleeps                                                   |
| `Java`        | External class lookup and Minecraft client access                            |
| `Reflect`     | Advanced direct method, field, and construction helpers for external objects |
| `GlobalVars`  | Shared booleans across scripts                                               |

`GlobalVars` exposes `get(key)`, `put(key, value)`, and `toggle(key)`.

`Sound.play(name, volume?, pitch?)` plays a file from `.minecraft/selvut/sounds` (or a built-in custom sound) and returns whether it played. `Sound.list()` returns the available names. Pair with the `sound_play` event (see [Lifecycle & Events](/scripting/lifecycle-events)) to replace or mute matched sounds by id.

## Inventory, KeyBind, Rotation, Interaction

| API           | Common functions                                                                                                                                                                             |
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Inventory`   | `getTitle`, `getSize`, `getContainerSlots`, `isOpen`, `getSlot`, `hotbarSlot`, `find`, `findAll`, `count`, `slots`, `click`, `quick`, `drop`, `swap`, `getCarried`, `open`, `closeContainer` |
| `KeyBind`     | `setRaw`, `pressRaw`, `releaseRaw`, `setBinding`, `pressBinding`, `releaseBinding`, `holdBinding`, `isBindingDown`, `getBindings`                                                            |
| `Rotation`    | `aimAt`, `snap`, `clear`, `active`, `blocked`, `yaw`, `pitch`, `normalizeYaw`, `normalizePitch`, `snapToGcd`, `snapDeltaToGcd`                                                               |
| `Interaction` | `attack`, `interactEntity`, `use`, `useItem`, `rayTrace`, `clickBlock`, `punchBlock`                                                                                                         |

## Async And Pathfinder

| API          | Common functions                                                       |
| ------------ | ---------------------------------------------------------------------- |
| `Async`      | `run`, `main`, `after`, `ticks`, `every`, `until`, `request`, `cancel` |
| `Pathfinder` | `find`, `findBetween`, `follow`, `hasDirectWalkLine`, `floorY`         |

`Async` functions return handles with `id`, `kind`, `cancel()`, `running()`, `done()`, `failed()`, `error()`, and `result()`.
`Async.request({ url = "...", binary = true }, callback)` returns `response.bodyBytes` / `response.bytes` as a Java byte array and `response.length` for binary data.

`Pathfinder.find(...)` returns a path object with `nodes`, `size()`, `empty()`, `length()`, and `node(index)`. `Pathfinder.follow(...)` returns a handle with `active()`, `finished()`, `failed()`, `stop()`, `tick()`, `frame()`, `repath()`, `path()`, and movement tuning methods.

## Render, Texture, Shader, Hud

| API       | Common functions                                                                                                                                                                                                                                                 |
| --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `Anim`    | `clamp01`, `lerp`, `easeOutCubic`, `easeInOutCubic`, `pulse`                                                                                                                                                                                                     |
| `Render`  | `rect`, `roundedRect`, `text`, `textWidth`, `fontHeight`, `cameraPosition`, `cameraRotations`, `image`, `item`, `entityGui`, `box`, `filledBox`, `block`, `line`, `tracer`, `isInView`, `assets`, `pushScissor`, `popScissor`, `worldToScreen`, `flush`, `toGui` |
| `Texture` | `loadUrl`, `loadBytes`, `release`                                                                                                                                                                                                                                |
| `Shader`  | `folder`, `list`, `reload`, `load`, `inline`, `uniform`, `uniforms`, `clearUniform`, `exists`, `use`, `target`, `removeTarget`, `clearTargets`                                                                                                                   |
| `Hud`     | `createElement`, `element`                                                                                                                                                                                                                                       |

`Render.text` accepts either positional arguments or an options object. Use `scale` for per-call text sizing, and `align` / `valign` when using the options form. The options form also takes `tiny` (pixel font) and `style` (`"shadow"`, `"outline"`, or `"none"`, replacing the plain `shadow` boolean when set):

```lua theme={null}
Render.text("Small label", 8, 8, Color.rgb(180, 190, 200), false, 0.8)
Render.text({ text = "Large label", x = 80, y = 20, color = Color.WHITE, shadow = true, scale = 1.2, align = "center" })
Render.text({ text = "Outlined tiny", x = 8, y = 40, color = Color.WHITE, style = "outline", tiny = true })
```

`Render.textWidth(text, scale?, tiny?)` and `Render.fontHeight(scale?, tiny?)` accept the same scale and `tiny` values for layout, so measurements match what `Render.text` will actually draw.

`Texture.loadUrl(url, options?)` and `Texture.loadBytes(bytes)` return script-owned handles. `options.timeoutMs` controls URL load timeout. Handles expose `ready()`, `loaded()`, `failed()`, `released()`, `status()`, `error()`, `identifier()`, `width()`, `height()`, and `release()`.

```lua theme={null}
local cover = Texture.loadUrl("https://example.com/cover.png")

Script.on("render2d", function()
  Render.image({ texture = cover, x = 8, y = 8, w = 32, h = 32, radius = 6 })
end)
```

`Render.image` accepts `radius` for rounded image corners. Textures are released automatically with the script runtime. Call `release()` when replacing one texture with another.

`Render.pushScissor(x, y, w, h)` takes local GUI coordinates and follows active HUD scaling/transforms. Use `Render.popScissor()` after drawing the clipped region.

`Hud.createElement(name, options)` returns a handle with `enable`, `disable`, `remove`, `enabled`, `render(fn)`, `size(w, h)`, `position(x, y, anchor)`, `scale(value)`, `description(text)`, and `settings`. `options.description` sets the HUD element description.

Use `hud.settings.bool`, `number`, `int`, `text`, `mode`, `color`, `key`, and `multiMode` for options that belong to that HUD element. They use the same shape as `Setting.*`, but appear and save with the HUD element instead of the script module.

HUD render events include `x`, `y`, `width`, `height`, `scaledWidth`, `scaledHeight`, `scale`, `screenWidth`, `screenHeight`, `centerX`, `centerY`, `anchor`, `horizontal`, and `vertical`. Use `horizontal` / `vertical` to adapt layout when an element is near the left, center, right, top, or bottom of the HUD.

```lua theme={null}
local hud = Hud.createElement("Track", { width = 180, height = 44 })
local cover = Texture.loadUrl("https://example.com/cover.png")

hud.render(function(e)
  local right = e.horizontal == "right"
  Render.image({ texture = cover, x = 6, y = 6, w = 32, h = 32, radius = 7 })
  Render.text({ text = "Song title", x = right and e.width - 8 or 46, y = 10, align = right and "right" or "left" })
end)
```

## Packet

| Function                                                                                    | Description                                        |
| ------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| `Packet.chat(text)` / `command(text)`                                                       | Send chat or command text                          |
| `Packet.swing(hand?)`                                                                       | Send hand swing                                    |
| `Packet.useItem(handOrOptions?)`                                                            | Send item use with optional `hand`, `yaw`, `pitch` |
| `Packet.useBlock(posOrOptions, options?)`                                                   | Send block use with `face`, `hand`, optional `hit` |
| `Packet.attack(entity, options?)`                                                           | Send entity attack                                 |
| `Packet.interact(entity, options?)` / `interactAt(entity, hit, options?)`                   | Send entity interaction                            |
| `Packet.setHeldSlot(slot)`                                                                  | Send held hotbar slot                              |
| `Packet.closeContainer(idOrOptions?)`                                                       | Send a container close packet                      |
| `Packet.releaseUseItem()` / `drop()` / `dropStack()` / `swapOffhand()`                      | Common player actions                              |
| `Packet.startDestroyBlock(pos, face?)` / `stopDestroyBlock(...)` / `abortDestroyBlock(...)` | Block break actions                                |
| `Packet.rotate(yaw, pitch, options?)`                                                       | Send rotation-only movement packet                 |
| `Packet.position(pos, options?)` / `positionRotation(pos, yaw, pitch, options?)`            | Send position movement packets                     |
| `Packet.send(packet, bypass?)` / `replay(packet)` / `bypass(packet)` / `info(packet)`       | Raw packet helpers                                 |

Packet helpers accept wrapper objects returned by `Player`, `World`, and `Inventory`. Most send helpers also accept an options object; common keys are `hand`, `face`, `hit`, `sequence`, `onGround`, and `bypass`.
