> For the complete documentation index, see [llms.txt](https://fehdead.gitbook.io/npc-kit/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/getx.md).

# npc.getx

```lua
npc.getx()
```

|                         |                                                                    |
| ----------------------- | ------------------------------------------------------------------ |
| id                      | `0x006D`                                                           |
| arguments               | 0                                                                  |
| result                  | Float: goes to the very next call, or to `npc.lua(npc.getx(), fn)` |
| in NPC Kit              | yes                                                                |
| measured from a kit NPC | returns                                                            |
| vanilla scripts         | 1003 calls in 173 of 1114 scripts                                  |

## What it does

Gives the NPC's x position. A result. [gety](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/gety.md) and [getz](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/getz.md) give the others.

## Result

The x, a float.

## Timing

Returns at once.

## In NPC Kit

Vanilla computes points from it (`getx() + sin(h) * 1.5`), which a recorded script can't: a result only reaches the next call as its first argument. Compute positions in Lua when `npc.add` runs, from the coordinates you placed the NPC at. In `npc.lua` it arrives cut to an integer.

## Used with

* [gety](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/gety.md), [getz](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/getz.md), [getrotangzx](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/getrotangzx.md).

## Example

Points around the NPC are computed in Lua when `npc.add` runs, from where you placed it:

```lua
local home = { 29.36, -9.0, 68.65 }

main = function()
    npc.aturn(home[1] + 3.0, home[2], home[3]);
    npc.move(home[1] + 3.0, home[2], home[3]);
    npc.wait(60);
    npc.aturn(home[1], home[2], home[3]);
    npc.move(home[1], home[2], home[3]);
    npc.wait(60);
end,
```

## Pitfalls

* `npc.getx() + 3.0` fails at `npc.add`: a result can't take part in arithmetic.
