
# Lua scripting

A script declares a module with settings and event handlers. The module appears in the
Scripts tab next to the built-in ones, and its settings persist the same way.

```lua title="hello.lua"
local module = ui.create("code", "Hello")

module:event("tick", function()
    print("tick")
end)
```

## Where scripts live

```text
<Minecraft config folder>/kawaki/scripts/*.lua
```

One top-level `.lua` file is one script. The folder is created on first launch, with editor
stubs beside it (`library/`, `docs/`, `.luarc.json`).

## Reload

| You do | The client does |
|--------|-----------------|
| Save a file | Reloads the script, keeping setting values and enabled state |
| Add a file | Loads it |
| Delete a file | Unloads its modules |

Every load, reload and unload prints a `lua »` line in chat.

## Errors

A load error prints in chat and the script is skipped. An error inside a callback prints and
disables the module, so it cannot spam every tick. Fix the file and save.

## Where to go next

- [First module](getting-started.md) — four steps to a working module, plus editor setup
- [Settings](settings.md) — sliders, colors, hotkeys and everything else on a panel
- [Events](events.md) — every event, its fields and what you may write back
- [world](world.md) — entities, blocks, raycasts, weather
- [2D canvas](canvas.md) — draw over the game
- [Examples](examples.md) — full modules to copy
