Reference/Native_modules

A native module is a shared library that adds new global functions to the server VM. It is loaded from a script with LoadModule("name"), which opens Modules/name.dll (Windows) or Modules/name.so (Linux). Up to 32 modules.

ExportSignatureWhen it is called
SQLoadSQRESULT SQLoad(HSQUIRRELVM v, SQAPI api)Once, on load. Register your functions here with the supplied Squirrel API table. Required.
SQUnloadSQRESULT SQUnload(void)When the server shuts down or scripts reload.
SQCallbackSQRESULT SQCallback(unsigned int callback, void* data)Reserved for custom event callbacks.
SQPulseSQRESULT SQPulse(void)Every server tick (about every 10 ms). Keep it fast.

The SQAPI pointer is a table of about 130 function pointers that mirror the Squirrel C API (sq_pushstring, sq_newclosure, sq_getinteger, ...), so a module needs no Squirrel library of its own. LoadModule returns false (and prints the reason in the console) if the file is missing or has no SQLoad.

Pages

Source code

Source code of the bundled modules (lu_ini, lu_http, lu_sqlite2).

Categories: Native modules