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

# npc.distance3d\_291

```lua
npc.distance3d_291(actor, x, y, z)
```

|                         |                                                                                 |
| ----------------------- | ------------------------------------------------------------------------------- |
| id                      | `0x0291`                                                                        |
| arguments               | 4: Int, Float, Float, Float                                                     |
| result                  | float: goes to the very next call, or to `npc.lua(npc.distance3d_291(...), fn)` |
| in NPC Kit              | yes                                                                             |
| measured from a kit NPC | returns                                                                         |
| vanilla scripts         | 133 calls in 11 of 1114 scripts                                                 |

## What it does

Gives the straight-line distance from an actor to a point, height counted. A result. [distance\_290](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/distance_290.md) leaves the height out.

## Arguments

### `actor` (Int)

`-1` the character the player controls, in the kit another NPC with `npc.actor("id")` (in a talk).

### `x` (Float)

### `y` (Float)

### `z` (Float)

The point; `y` is the height.

## Result

The distance, a float.

## Timing

Returns at once.

## In NPC Kit

Vanilla passes `-1` and the NPC's own `getx()`, `gety()`, `getz()`, to ask how far the player is; a result only reaches the next call as its first argument, so in the kit write the NPC's coordinates as numbers. `npc.lua` hands the distance to Lua cut to an integer.

## Used with

* [checkdistance3d\_531](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/checkdistance3d_531.md): the same test as a yes or no.
* [getlength3](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/getlength3.md): from the NPC itself.

## Example

A lookout on a ledge who tells the player how far below they stand.

```lua
local perch = [[
You're about %d paces away from my perch now.
Come a little closer if you want to hear more.
]]

talk = function()
    talkOpen();
    npc.lua(npc.distance3d_291(-1, 42.3, 6.0, 88.8), function(handle, d)
        say(handle, perch:format(d))
    end);
    talkClose();
end,
```
