> For the complete documentation index, see [llms.txt](https://0x29a.gitbook.io/0x29a-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://0x29a.gitbook.io/0x29a-docs/introduction/lifecycle.md).

# Lifecycle & scheduler

The engine drives a `__neuro_tick(dt)` once per frame, on the render thread. The bootstrap uses that to implement a simple scheduler exposed as `_29a.*` (with `neuro` as a back-compat alias — `neuro.on_frame` behaves identically to `_29a.on_frame`).

## `_29a.time()`

Returns the accumulated time, in milliseconds, since the engine started.

## `_29a.on_frame(fn)`

```lua
local id = _29a.on_frame(function()
    -- runs once per rendered frame
end)
```

* **Returns:** an `id` (integer) that can be passed to `_29a.remove(id)`.
* Errors inside `fn` are caught with `pcall` and printed to the console — an exception doesn't take down the other callbacks or the overlay.

## `_29a.after(ms, fn)`

Schedules `fn` to run **once**, after `ms` milliseconds.

```lua
_29a.after(3000, function()
    print("3 seconds have passed")
end)
```

## `_29a.every(ms, fn)`

Like `after`, but repeats indefinitely every `ms` milliseconds.

```lua
local id = _29a.every(1000, function()
    print("1s tick")
end)

-- later:
_29a.remove(id)
```

* **Returns:** an `id` for use with `_29a.remove`.

## `_29a.remove(id)`

Removes an `on_frame` callback or a timer (`after`/`every`) by the `id` returned when it was registered.

## `_29a.clear()`

Removes **every** frame callback and every timer at once. Useful from a thread's `__neuro_on_stop`, or when manually reloading a script.

## `_29a.register_settings(...)` / `_29a.menu_is_open()`

Thin bridges to the script-settings registry in the overlay's settings tab, and to whether the main menu (INSERT) is currently open — useful to pause heavy logic (scans, drawing) when the user isn't looking at the menu.

```lua
if _29a.menu_is_open() then
    -- only draw debug overlays while the menu is visible
end
```

## Execution order

1. The DLL injects and creates the main Lua state (`Engine::MakeState`).
2. The bootstrap (compiled, not a file) runs first — it defines `_29a`, `bind`/`unbind`, the global helpers.
3. Your scripts (`scripts/` folder) load on top of that.
4. Every frame, `__neuro_tick(dt)` fires the `on_frame` callbacks, processes pending timers, then the hotkeys registered via `bind`.

See also [Hotkeys](/0x29a-docs/introduction/hotkeys.md) and the [thread](/0x29a-docs/runtime/thread.md) reference for logic that needs to run outside the render frame.


---

# 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://0x29a.gitbook.io/0x29a-docs/introduction/lifecycle.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.
