> 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/examples/give-item.md).

# Giving an Item

**NPCKit 0004 says one line, then gives you a Potion with the game's own notice.**

This example takes place on map id 290, Rabanastre / Muthru Bazaar.

Download: [give-item.lua](https://github.com/FelipeJulio/NPC-Kit/tree/main/examples/give-item.lua)

```lua
local ok, npc = pcall(require, "scripts.NPCKit.Helper")
if not ok then
    print("Couldn't install, NPC Kit is missing.")
    return
end

local greeting = [[
You look tired, traveler. The bazaar wears down
even the strongest of us. Here, take this one.
]]

local advice = [[
A potion, fresh from the apothecary this morning.
Drink it when your wounds start to slow you down.
]]

local idle, talking = 0x01000000, 0x01000002

local potion = 0x0000

local function placeNpc(model, x, y, z, heading)
    npc.setautorelax(1);
    npc.usecharhit(0);
    npc.bindp2_d4(model, 4, 3);
    npc.stdmotionread(16);
    npc.stdmotionreadsync();
    npc.stdmotionplay_2c2(idle, 0);
    npc.setoverheadicontype(0);
    npc.usemapid(1);
    npc.usecharhit(1);
    npc.setweight(-1);
    npc.set_ignore_hitgroup(1);
    npc.motionloop(1);
    npc.setpos2(x, y, z);
    npc.dir(heading);
    npc.fetchambient();
    npc.bonecalcforce(-1);
    npc.clearhidecomplete();
    npc.show();
    npc.showshadow();
end

local function talkOpen()
    npc.sethpmenu(0);
    npc.ucoff();
    npc.settrapshowstatus(0);
    npc.setaturnlookatlockstatus(0);
    npc.raturna(-1);
    npc.turnsync();
    npc.stdmotionplay_2c2(talking, 20);
    npc.setkutipakustatus(1);
    npc.setunazukistatus(1);
end

local function talkClose()
    npc.setkutipakustatus(0);
    npc.setunazukistatus(0);
    npc.lookatoff();
    npc.ucon();
    npc.sethpmenu(1);
    npc.clear_force_char_nearfade();
    npc.setmaphighmodeldepth(-1);
    npc.setmapmodelstatus(1);
    npc.setstatuserrordispdenystatus(0);
    npc.settrapshowstatus(1);
    npc.stdmotionplay_2c2(idle, 20);
end

local function talkTerm()
    npc.setaturnlookatlockstatus(1);
    npc.aturn_261(npc.getdestrotangzx_227(0));
end

local function giveItem(item, count)
    npc.musictrans(-1, 30, 32);
    npc.setstatuserrorctrldenystatus_by_menu(1);
    npc.seteventtimestop(1);
    npc.moveblurcaptureonce();
    npc.movebluraplpha(1);
    npc.moveblurfade(15);
    npc.moveblurfadesync();
    npc.sebsoundplay(0, 40);
    npc.additemmes(item, count);
    npc.musictrans(-1, 30, 127);
    npc.moveblurclearfade(15);
    npc.moveblurfadesync();
    npc.seteventtimestop(0);
    npc.setstatuserrorctrldenystatus_by_menu(0);
end

local function myMod()
    npc.add {
        id = "npckit_0004",
        map = 290,
        name = "NPCKit 0004",

        init = function()
            placeNpc(0x006E0018, 28.9, -9.0, 61.5, 3.1416);
        end,

        main = function()
            npc.wait(60);
        end,

        give = function()
            giveItem(potion, 1);
        end,

        talk = function()
            talkOpen();
            npc.lua(function(handle)
                if not dialog.amese.open {
                        speaker = "NPCKit 0004",
                        body = greeting,
                        queue = true,
                        onClose = function()
                            handle.run("give", function()
                                if not dialog.amese.open {
                                        speaker = "NPCKit 0004",
                                        body = advice,
                                        queue = true,
                                        onClose = function() handle.finish() end,
                                        onError = function() handle.finish() end
                                    } then
                                    handle.finish()
                                end
                            end)
                        end,
                        onError = function() handle.finish() end
                    } then
                    handle.finish()
                end
            end);
            talkClose();
        end,

        talkterm = talkTerm
    }
end

event.registerEventAsync("onInitDone", myMod)
```

`additemmes(id, count)` gives the item and shows the notice. Vanilla wraps it the way `giveItem` does: it blurs the screen behind the notice, pauses the event time and lowers the music, then clears the blur and puts everything back. Without `moveblurclearfade` the notice leaves the screen darker each time. Ids are in [Inventory Contents](https://fehdead.gitbook.io/ffxii-modding-guide/modding/resources/inventory-contents). After the notice it says one more line. It gives one every time you talk to it: keep your own flag in Lua to give it once.
