pNPC is a library for getting a wrapper object for NPC class objects LunaLua, which unlike those remains valid across ticks.
For extra utility it also provides a uid and a property for user-defined data storage.
Place the file pnpc.lua in either your level's custom graphics folder for use in a level, along with a lunadll.lua file, or in the same directory as your .wld file along with a lunaworld.lua file for use throughout an entire episode.
How to use
To enable the pNPC library for a specific level, add this line to lunadll.lua:
local pNPC = API.load("pnpc");
This will load the pNPC API.
External Use Functions
These are functions you will need to use the library
|Get a wrapper around a specified NPC which will remain valid across ticks. If one already exists, it is returned, otherwise a new one is created.||NPC-like Wrapper||NPC
The NPC to wrap.
|Get a wrapper around a specified NPC which will remain valid across ticks. If one doesn't already exist, return nil.||NPC-like Wrapper||NPC
The NPC to find the wrapper for
The NPC Wrapper
All properties supported by LunaLua's NPC class are automatically supported.
The mem and kill methods are also supported.
There are four additional properties defined:
|data||A table which user-defined data associated with the NPC can be entered into|
|uid||(read-only)||A unique identifier for this NPC|
|pid||(read-only)||The persistence identifier for this NPC. If the uid is less than 0x8000, it is guaranteed to be the same as pid. Intended for debugging.|
|pidIsDirty||(read-only)||Flag to indicate that the persistence identifier is recycled. Intended for debugging.|