NAME
modules - Install and write game modules
DESCRIPTION
Neverdark is not one game. It is a boot engine plus a set of modules, one shared library each, loaded into regions. A module can add commands, tables and event handlers that run only for the players of the region it is loaded into, so different corners of the world can be different games.
Installing a module
A module is a shared library named libnd-name.so, installed on the engine's library path - the directory the engine itself lives in. loadmod loads it by bare stem, without the suffix:
loadmod libnd-core
A module attaches to one region, not to the whole world: you must rule the exact region you load into (see loadmod(10)). The set is remembered in the region's row and restored on every boot. modlist(10) shows a region's modules and unloadmod(10) takes one out; grant(10) hands a finished region to another player.
Writing a module
A module is an ordinary shared object built against the engine headers. Its contract is small:
- include <nd/xy.h>;
- export XY_MODULE_API void xy_install(void) for setup;
- implement event hooks with XY_IMPL (the hook list is in nd/hooks.h);
- export services to other modules with XY_DECL plus XY_IMPL;
- write to a player with nd_printf, and read and write persistent tables with nd_get and nd_put.
Dependencies are declared at install time with xy_load, so a module names what it needs instead of assuming a load order. Build the result as libnd-name.so and place it beside the engine.
The unix subsystem, reached with sh(10), is the workbench: edit sources, run the build, and reload in place.
SEE ALSO
loadmod(10), unloadmod(10), modlist(10), release(10), grant(10), target(10), sh(10), begin(10)
AUTHOR
quirinpa <quirinpa@tty.pt>