PNPC.lua

'''Warning: This library has been deprecated since SMBX2 Beta 4. In this version and onwards, npc.data, npc.uid, npc.pid, and npc.pidIsDirty can be accessed without needing to use this library.'''

Download Latest Version

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.

Installation
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: This will load the pNPC API.

After loading we can wrap NPC objects, which gives them a data table we can read values from/write values to.

Note: It is also sometimes useful when needing to initialize/reset a large number of data values to have an additional helper function to do the work. Then we can call it as needed to initialize/reset these values.

The following is a brief example that stops all goombas (in the player's section) from moving 150 ticks after they are spawned.

External Use Functions
These are functions you will need to use the library

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: