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

# Quick Start

## Quick Start

{% stepper %}
{% step %}

#### Open the Lua tab

Click the code icon in the top bar.
{% endstep %}

{% step %}

#### Create a script

Sidebar → **Create LUA**, type a name (plain text prompt, no code needed for this step).
{% endstep %}

{% step %}

#### Paste your code

Paste your code into the editor.
{% endstep %}

{% step %}

#### Save and Start

Click **Save**, then **Start**.
{% endstep %}
{% endstepper %}

### Minimal script

```lua
local enabled = ui.switch("Lua", "example", "main", "draw", true)

events.render:set(function()
    if not enabled:get() then return end

    local w, h = render.screen_size()
    render.text("verdana", { w * 0.5, h * 0.9 }, { 1, 1, 1, 1 }, "hello", "c")
end)

on_shutdown(function()
    print("script unloaded")
end)
```

### Typical structure

```lua
local enabled = ui.switch("Category", "script_name", "section", "enabled", true)

events.update:set(function()
    -- cheap per-frame logic / state caching
end)

events.render:set(function()
    if not enabled:get() then return end
    -- drawing
end)

on_shutdown(function()
    -- cleanup, e.g. print stats
end)
```

### Logging

```lua
print("info", 42)          -- "[lua:script] info 42"
print_error("bad thing")   -- "[lua:script][ERROR] bad thing"
print_warn("heads up")     -- "[lua:script][WARN] heads up"
print_chat("chat line")    -- "[lua:script][CHAT] chat line" (log only, does not post to in-game chat yet)
print_raw("no timestamp/tag prefix, printed as-is")
```

{% hint style="info" %}
All of the above append to the output shown in the Lua tab's editor (capped at 8KB, oldest lines drop first) and to `func.log` via the crash logger.
{% endhint %}

### Error handling

Script-level errors (top-level load/run, or inside `events.update`/`events.render`) never crash the app — they're caught, shown in the Lua tab's **Output** panel, and logged once (deduplicated) to `func.log`.

```lua
local ok, err = pcall(function()
    return some_risky_call()
end)

if not ok then
    print_error("failed: " .. err)
end
```


---

# 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://docs.autowall.fun/documentation/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.
