Extending the functionalities of nanos world Scripting API
Modules allows you to extend the functionality of the nanos world scripting API on the server side. Currently only C modules are supported.
Be aware that this part of the scripting API is currently work in progress and may change at any time.
Creating your own C module
It is also possible to you create your own C/C++ module and call it's functions from nanos world.
This is an advanced procedure so instabilities and even crashes may occur.
To create your own module, fist make sure you have Visual Studio installed with Desktop development with C++ (and CMake) or any other C compiler on Linux.
- Then, clone our example module in your computer to get start with it.
- After cloning, you will need to download it's submodules with
git submodule update --init --recursive- this will download the module-sdk as a git submodule into deps/ folder automatically.
Understanding the example
The important file is under
Compiling your C module
To compile the example, follow the steps:
- Create a folder called
- Enter the build folder:
- Build it with
cmake --build . --config Release
And now you will have the dlls/libs in
Using your C module
Now copy the
.dll file into your nanos world
And in your Package, you can load and use it like:
-- Loads the module 'example'
local example = require('example')
-- Calls the module function 'test'
-- Will print 'Hello World' on console