# Welcome

Welcome to the official **Lua Scripting API** reference.

***

## Editor Setup

Install the **axeprime Language Server** extension for Lua intellisense, autocomplete, and inline API documentation.

| Editor      | Install                                                                                                               |
| ----------- | --------------------------------------------------------------------------------------------------------------------- |
| **VS Code** | [marketplace.visualstudio.com](https://marketplace.visualstudio.com/items?itemName=axeprime.axeprime-language-server) |
| **Cursor**  | [open-vsx.org](https://open-vsx.org/extension/axeprime/axeprime-language-server)                                      |

> Both editors use the same extension from the VS Code Marketplace.

***

## Runtime

Scripts run on **LuaJIT 2.1.0** (Lua 5.1 compatibility).

| Feature           | Details                                                     |
| ----------------- | ----------------------------------------------------------- |
| **Lua version**   | 5.1                                                         |
| **JIT**           | LuaJIT 2.1.0 — [Download](http://axeprime.cloud/luajit.rar) |
| **`bit` library** | Available globally — no `require` needed                    |
| **Sandbox**       | Enabled by default; some APIs require permission            |

***

## Script Directories

> **Scripts:** `<game_dir>/bin/win64/axe/scripts/` **Resources:** `<game_dir>/bin/win64/axe/scripts/resources/` **Libraries:** `<game_dir>/bin/win64/axe/scripts/lib/`

Scripts are placed in the **scripts** directory as `.lua` files and are loaded directly by the engine.

**Examples:**

* `<game_dir>/bin/win64/axe/scripts/advanced.lua`
* `<game_dir>/bin/win64/axe/scripts/menu.lua`

***

## Using Libraries (`require`)

Libraries are placed inside the **lib** subdirectory and can be loaded using `require()`.

The engine automatically searches modules in the following order:

1. `scripts/`
2. `scripts/lib/`
3. `scripts/modules/` *(if available)*

The `require()` system supports dot-notation, which maps to subfolders.

```lua
local UI = require("apex_ui")
-- searches: scripts/apex_ui.lua → scripts/lib/apex_ui.lua

local math_utils = require("utils.math")
-- searches: scripts/utils/math.lua → scripts/lib/utils/math.lua

local targeting = require("ragebot.targeting")
-- searches: scripts/ragebot/targeting.lua → scripts/lib/ragebot/targeting.lua → scripts/modules/ragebot/targeting.lua
```

***

## Permission System

Scripts are **sandboxed by default**. Some features require user approval:

| Permission      | Trigger                                             |
| --------------- | --------------------------------------------------- |
| **FFI**         | Using `require("ffi")` or `ffi.*`                   |
| **Insecure**    | Using `os.execute`, `io.popen`, etc.                |
| **File Access** | Using `fs.read/write/remove`, `fs.create_dir`       |
| **HTTP**        | Using `http.*` functions (HTTP and HTTPS supported) |
| **Sound**       | Using `sound.*` functions                           |


---

# Agent Instructions: 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:

```
GET https://lua.axeprimecs.com/readme.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
