> 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/vars/memory.md).

# Memory

## Memory API

Low-level, **read-only** raw memory access, so you can chain pointer offsets yourself with plain Lua arithmetic instead of needing a bespoke offset-chaining DSL:

```lua
memory.base()             -- integer, UnityFramework module base (memory_manager::base)
memory.local_player()      -- integer, local player controller address (same value as
                             -- entity.get_local_player_addr(), just under this table too)

memory.read_i8(addr)   memory.read_u8(addr)
memory.read_i16(addr)  memory.read_u16(addr)
memory.read_i32(addr)  memory.read_u32(addr)
memory.read_i64(addr)  memory.read_u64(addr)
memory.read_ptr(addr)      -- alias of read_u64 -- read a pointer-sized value
memory.read_float(addr)
memory.read_double(addr)
memory.read_string(addr, max_len?)   -- reads a null-terminated C string, max_len default/cap 256/4096
```

Every `read_*` returns `nil` (not an error, not a crash) if the address is unmapped/unreadable — reads go through `mach_vm_read_overwrite`, not a raw pointer dereference, specifically so a bad address fails gracefully instead of segfaulting the whole app.

### Chaining offsets

```lua
local player = memory.local_player()
local weaponry = memory.read_ptr(player + 0x98)
local current_weapon = memory.read_ptr(weaponry + 0x30)  -- made-up offset, illustrative
local weapon_id = memory.read_i32(current_weapon + 0x18)  -- made-up offset, illustrative

if weapon_id then
    print("weapon id: " .. weapon_id)
end
```

Offsets themselves aren't documented/maintained here (they change across game updates) — this API just gives you the primitives to read them once you know them.

### Why no `memory.write_*`

{% hint style="danger" %}
Deliberately not implemented. An arbitrary-write primitive exposed to *any* Lua script — including one pasted from someone else, since scripts are just text files — is a meaningfully bigger risk than a read: a bad read just returns `nil`, but a write to an arbitrary address can corrupt the running process or be a real exploitation primitive, not just a "the cheat crashed" one. If you need to *set* something specific, ask for a named accessor (like `entity.set_prop`, not yet implemented either — see Roadmap) instead of raw writes.
{% endhint %}


---

# 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/vars/memory.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.
