> For the complete documentation index, see [llms.txt](https://kaizo-1.gitbook.io/kaizo-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kaizo-1.gitbook.io/kaizo-docs/lua-engine/quick-start.md).

# Quick start

This page shows the most useful Lua stuff fast. Put a file in your scripts folder, turn on Enable scripts, then hit Run.

## Minimal script

```lua
function on_load()
    log.info("loaded")
    toast.push("hello")
    hud.register_module("Demo")
end

function on_draw(draw)
    local players = world.players()
    draw.rect_filled(20, 80, 240, 112, 0xCC15161A, 6)
    draw.text(32, 89, 0xFFFFFFFF, "players: " .. #players)
end

function on_unload()
    hud.unregister_module("Demo")
end
```

## Most useful pieces

### Hooks

* `on_load` setup once
* `on_tick(dt)` logic every frame
* `on_draw(draw)` overlay drawing
* `on_ui` menu UI when Insert is open

### Overlay

* `toast.push` popup on screen
* `draw.text` and `draw.rect_filled` for simple HUD panels
* `hud.register_module` chip on the module list

### Game data

* `world.players()` all players
* `world.resolved()` filtered targets for ESP style loops
* `input.was_pressed(keys.F1)` one shot keys (see `keys` macros)
* `config.get` / `config.set` read and write cheat settings

### SDK

* `sdk.local_player()` then `sdk.character` and `sdk.humanoid_root_part`
* `sdk.position` / `sdk.set_position`
* `sdk.teleport_to` / `sdk.teleport_stop`

### Raw memory

Only when you need it.

* `unsafe_memory.module_base()`
* `unsafe_memory.read_u64` / `write_u64`

## Full example

```lua
local show = true

function on_load()
    toast.push("quick start loaded")
    hud.register_module("Quick")
end

function on_tick(dt)
    if input.was_pressed(keys.F1) then
        show = not show
        toast.push(show and "hud on" or "hud off")
    end
end

function on_draw(draw)
    if not show then
        return
    end

    local resolved = world.resolved()
    local players = world.players()
    local y = 90

    draw.rect_filled(20, 70, 280, 90 + (#resolved * 18), 0xCC15161A, 6)
    draw.text(32, 78, 0xFFFFFFFF, "targets: " .. #resolved)

    for _, t in ipairs(resolved) do
        local p = players[t.player_index]
        if p then
            local name = p.display_name or p.username
            draw.text(32, y, 0xFFFFFFFF, string.format("%s  %.0f", name, t.distance))
            y = y + 18
        end
    end
end

function on_ui()
    if not world.screen().menu_open then
        return
    end

    if ui.begin_window("Quick", 280, 140) then
        ui.text("F1 toggles the target list")
        if ui.button("Toast") then
            toast.push("hi from ui")
        end
    end
    ui.end_window()
end

function on_unload()
    hud.unregister_module("Quick")
end
```

## Where to go next

Each category has an Essentials page with the important functions for that area.

1. Getting started Essentials
2. Overlay Essentials
3. Game and session Essentials
4. SDK Essentials
5. Unsafe memory Essentials
6. MCP


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://kaizo-1.gitbook.io/kaizo-docs/lua-engine/quick-start.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
