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.
| Export | Signature | When it is called |
|---|---|---|
SQLoad | SQRESULT SQLoad(HSQUIRRELVM v, SQAPI api) | Once, on load. Register your functions here with the supplied Squirrel API table. Required. |
SQUnload | SQRESULT SQUnload(void) | When the server shuts down or scripts reload. |
SQCallback | SQRESULT SQCallback(unsigned int callback, void* data) | Reserved for custom event callbacks. |
SQPulse | SQRESULT 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
- The bundled modules
- lu_ini - INI files
- lu_http - web requests
- lu_sqlite2 - SQLite databases (object oriented)
- lu_sqlite - SQLite databases (original procedural module)
- lu_hashing - MD5 and SHA1
Source code
Source code of the bundled modules (lu_ini, lu_http, lu_sqlite2).
Categories: Native modules