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

# NPC Kit Editor

**A simple in-game frontend that makes writing NPCs easier. It's a helper for you, the mod's creator, not part of your mod.**

***

###

<figure><img src="https://3881308715-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBE6a3fWKKXWQg8lv0u6v%2Fuploads%2FEKky3aksY0GHRNBnhcff%2Fexample.avif?alt=media&amp;token=7d3ead48-2c7d-4f15-9d25-492481881cc6" alt=""><figcaption></figcaption></figure>

### What it is for

NPC Kit Editor is an overlay over the running game, opened with a key. It saves you the round trips between your script and the game while you set up an NPC:

* **See models in real time**, on the NPC, before you pick one.
* **Place an NPC** and **turn it**, and see where it stands.
* **See which ids to use**, such as the status ids the calls take.
* **Test** your NPC on the spot.

{% hint style="warning" %}
**The editor doesn't do miracles.** It's a frontend over the same VM calls you write by hand. It doesn't write dialogs, logic or routines for you, and it doesn't save a mod.
{% endhint %}

***

### It lists NPC Kit's NPCs

The editor lists the **NPC Kit NPCs on the current map**: the ones your mods declare with `npc.add` and the ones you add with the editor. Vanilla NPCs aren't in its list.

Pick an NPC at the top, or **add one**, then work on it: model, position, facing, its shots, and the rest.

**+ Add new** puts a new NPC in front of the leader, started the way vanilla NPCs start, so the player can't push it. Pick its kind:

| kind            | what it gets                                                                                                                                                                                                                    |
| --------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Puppet NPC**  | stands and idles                                                                                                                                                                                                                |
| **Talking NPC** | the same, with a talk: it turns to you, says *Hello.* and turns back. Its Code has the whole talk, laid out like the [Starting Template](https://fehdead.gitbook.io/npc-kit/api/starting-template.md), ready for your own lines |

***

### Every change shows at once

Change a value and the NPC changes in the game, with no Apply button. A change to its **Model** group (the model, its motion set, its variation and colour) rebuilds the map's NPCs, so it shows a moment later. Every row is named after the VM call it changes, and the search finds it by that name.

***

### Postures and motions

A model's motion set can hold more than one **posture**: standing, sitting on a chair, sitting on the floor. Pick the motion set in the **Model** group, then the posture in the **Motion** group; the NPC plays its idle in it at once.

The standard motions (idle, talking, turning, laughing, yes, no...) are listed by name. A **✓** marks the ones the NPC's motion set has in the posture it plays; one without it does nothing on that NPC.

**Replace motion**, in the **Model** group, plays another model's motion set on the NPC in place of its own: pick the model and the set, and the NPC plays its idle from it at once. The **Code** section then gives the `motionFrom` line for its `npc.add` (see [Custom Motion](https://fehdead.gitbook.io/npc-kit/api/custom-motion.md)).

{% hint style="info" %}
**A seated NPC needs its height.** On the ground the NPC takes the floor's height by itself. To set it on a chair or a ledge, turn the ground off in the **Body** group first (`usemapid`), then set its `y`. See [What Vanilla Does](https://fehdead.gitbook.io/npc-kit/api/what-vanilla-does.md).
{% endhint %}

***

### The Code section: from the editor to your script

When you edit an NPC, the editor's **Code** section shows the VM calls your edits come to. Copy them into your Lua script, in your NPC's `init` or wherever they belong. What the NPC *is* (its model, place, look, areas) comes under "add to its init"; what it *does* (a walk, a turn, a sound, an effect, a camera) comes last, commented out, because in `init` it would run at every map load: put those in `talk`, a named function or a scene.

```lua
init = function()
    -- the calls copied from the Code section
    npc.bindp2_d4(0x006E0019, 4, 3);
    npc.setpos2(29.36, -9.0, 68.65);
    npc.dir(1.676);
    npc.show();
end,
```

{% hint style="info" %}
**Your NPC is the Lua you write.** NPC Kit and its editor don't write any code for you. The editor only makes finding the right calls and values faster; the whole routine of the NPC, its talk and its dialogs, is written by you in Lua with the [NPC Kit API](https://fehdead.gitbook.io/npc-kit/api.md).
{% endhint %}

An NPC added with the editor lasts until the game closes. What keeps it in the game is the code you copy into your script.

***

### Custom camera: making your shots

The **Custom camera** group builds the fixed shots of an NPC's talk, the `cameras` of its `npc.add` (see [Custom Camera](https://fehdead.gitbook.io/npc-kit/api/custom-camera.md)). Pick the NPC at the top first: an NPC that already has `cameras` opens with its shots listed.

1. **Make a shot.**
   * **New shot** frames the NPC's face from in front, a good start to adjust.
   * **Capture shot** takes the view of the Free Camera mod: turn it on (F12), frame the shot, then Capture.
2. **Name it.** The **name** is what `npc.camera("name")` plays. Use the id of the NPC the shot frames, such as `npckit_0014`. A new shot already takes the picked NPC's id.
3. **Adjust it.** Each shot has a slider per value: **eye x, y, z** (where the camera is), **target x, y, z** (where it looks), **roll** and **fov** in degrees. Drag, or Ctrl+click to type a value. **↺** puts a value back to what the shot opened with.
4. **See it.** A shot shows as soon as you make it or change a value; **Preview** plays one again. **Stop preview** gives the camera back.
5. **Take it to your script.** **Copy bank** copies the `cameras = { ... }` table, and the **Code** section shows it too, once a shot changed. Paste it into the NPC's `npc.add`, and play a shot in its `talk`:

```lua
npc.add {
    id = "npckit_0014",
    ...
    cameras = {
        ["npckit_0014"] = { eye = { 38.0, -7.5, 63.0 }, target = { 39.0, -7.57, 62.65 }, fov = 33.0 },
        ["npckit_0015"] = { eye = { 39.4, -7.5, 63.0 }, target = { 37.5, -7.57, 62.56 }, fov = 33.0 },
    },
    talk = function()
        npc.camerastart_7e(0, npc.camera("npckit_0014"));
        ...
        npc.cameraclear();
    end,
}
```

{% hint style="warning" %}
**The shots you edit live only in the editor.** They are lost when the game closes or you pick another NPC. Copy them into your script before that.
{% endhint %}

***

### Don't ship the editor

{% hint style="danger" %}
**NPC Kit Editor must not be distributed with any mod.** It's a tool for the creator only: to edit the NPCs you make more easily, try things and run tests.
{% endhint %}

What a finished mod ships is:

| goes to players    | how                                                                    |
| ------------------ | ---------------------------------------------------------------------- |
| **your script**    | in your mod                                                            |
| **NPC Kit**        | as a dependency: players install it, your mod requires it              |
| ~~NPC Kit Editor~~ | never. Players don't need it, and it takes the game's input while open |

***

### Installing (for you, the creator)

NPC Kit Editor is a separate install, with its own Mod Config page for the key that opens and closes it. It needs NPC Kit and the [FF12 Lua Loader](https://fehdead.gitbook.io/ffxii-modding-guide/modding/resources/ff12-lua-loader-documentation) 2.0.1 or newer.

{% hint style="info" %}
While the editor is open, the game gets no keyboard, mouse or pad input. Close it with the same key to play again. Uninstall it when you're done writing NPCs.
{% endhint %}
