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

# npc.istownmap

```lua
npc.istownmap()
```

|                         |                                                                       |
| ----------------------- | --------------------------------------------------------------------- |
| id                      | `0x053C`                                                              |
| arguments               | 0                                                                     |
| result                  | int: goes to the very next call, or to `npc.lua(npc.istownmap(), fn)` |
| in NPC Kit              | yes                                                                   |
| measured from a kit NPC | returns                                                               |
| vanilla scripts         | 14686 calls in 818 of 1114 scripts                                    |

## What it does

Gives `1` when the current location is a town, `0` otherwise: the town bit of the location's entry in the game's location table. A result.

## Result

`1` or `0`.

## Timing

Returns at once.

## In NPC Kit

Vanilla tests it in `if`s, which a recorded script can't hold: read it in Lua, `npc.lua(npc.istownmap(), function(handle, town) ... end)`. A kit NPC lives on a map you chose, so you usually know already.

## Used with

* [suspendbattle](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/suspendbattle.md).

## Example

The talk of an NPC declared on several maps, pausing the battle only off-town: the choice is made in Lua when `npc.add` runs, from the map.

```lua
local safeTravels = [[
Safe travels, friend. The roads are long out there
so keep your blade sharp and your eyes open wide.
]]

local function declare(id, map, isTown)
    npc.add {
        id = id,
        map = map,
        name = "NPCKit 0060",
        init = function() placeNpc(0x006E0019, 10.0, 0.0, 20.0, 0.0); end,
        main = function() npc.wait(90); end,
        talk = function()
            if not isTown then npc.suspendbattle(); end   -- recorded or not, at npc.add
            talkOpen();
            npc.lua(function(handle) say(handle, safeTravels) end);
            if not isTown then npc.resumebattle(); end
            talkClose();
        end,
    }
end

declare("npckit_0060", 290, true)    -- Muthru Bazaar
declare("npckit_0061", 132, false)   -- The Yoma
```

To read it while the game runs: `npc.lua(npc.istownmap(), function(handle, town) ... end)`.
