Native modules
Load and call native modules through JSON.
Namespace: caffeine.native
load#
Lua: caffeine.native.load
text
load(name) -> boolean
Loads a native module. The load error is not reported to the script.
| Parameters | Type | Description |
|---|---|---|
name | string | Native module name. |
Returns: boolean. True when the module loaded.
Example
lua
caffeine.native.load('mymodule')
call#
Lua: caffeine.native.call
text
call(module, fn[, argsJson]) -> string
Calls a function of a loaded native module with JSON arguments.
| Parameters | Type | Description |
|---|---|---|
module | string | Module name. |
fn | string | Function name. |
argsJson | string | JSON arguments (default "{}"). |
Returns: string. The result text; on failure the error message is returned instead.
Example
lua
local out = caffeine.native.call('mymodule', 'ping', '{}')