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

# npc.setlightgroup

```lua
npc.setlightgroup(group)
```

|                         |                                  |
| ----------------------- | -------------------------------- |
| id                      | `0x0224`                         |
| arguments               | 1: Int                           |
| in NPC Kit              | yes                              |
| measured from a kit NPC | returns                          |
| vanilla scripts         | 643 calls in 101 of 1114 scripts |

## What it does

Adds the NPC to one of the map's light groups. The groups are a mask, one bit each: the NPC keeps the groups it already had; `clearlightgroup(group)` takes one away.

## Arguments

### `group` (Int)

The group, 0 to 31 (only the low 5 bits count). Vanilla: `1`, `4`, `2`, `5`, `7`, `3`, `6`. Which groups a map has is in the map's own data; none is bundled here.

## Timing

Returns at once.

## In NPC Kit

The kit examples light their NPCs with [fetchambient](https://fehdead.gitbook.io/npc-kit/vm-reference/calls/fetchambient.md) instead. Not tested on a kit NPC.

## Used with

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

## Example

The vanilla shape, in `init`. Which groups the map has is in its data; try values in the game.

```lua
init = function()
    -- ...
    npc.setlightgroup(1);
    npc.fetchambient();
    -- ...
end,
```

## Pitfalls

* It adds, it does not replace: to move the NPC to another group, `clearlightgroup` the old one.
* Not tested on a kit NPC.
