2023-07-11 02:32:59 +00:00
|
|
|
---
|
|
|
|
title: Interface hilbish.module
|
|
|
|
description: native module loading
|
|
|
|
layout: doc
|
|
|
|
menu:
|
|
|
|
docs:
|
|
|
|
parent: "API"
|
|
|
|
---
|
|
|
|
|
|
|
|
## Introduction
|
|
|
|
The hilbish.module interface provides a function
|
|
|
|
to load Hilbish plugins/modules.
|
|
|
|
Hilbish modules are Go-written plugins (see https://pkg.go.dev/plugin)
|
|
|
|
that are used to add functionality to Hilbish that cannot be written
|
2023-07-11 02:45:49 +00:00
|
|
|
in Lua for any reason.
|
2023-07-11 02:32:59 +00:00
|
|
|
|
|
|
|
To make a valid native module, the Go plugin
|
|
|
|
has to export a Loader function with a signature like so:
|
2023-07-11 02:45:49 +00:00
|
|
|
`func(*rt.Runtime) rt.Value`.
|
|
|
|
|
2023-07-11 02:32:59 +00:00
|
|
|
`rt` in this case refers to the Runtime type at
|
|
|
|
https://pkg.go.dev/github.com/arnodel/golua@master/runtime#Runtime
|
2023-07-11 02:45:49 +00:00
|
|
|
|
2023-07-11 02:32:59 +00:00
|
|
|
Hilbish uses this package as its Lua runtime. You will need to read
|
|
|
|
it to use it for a native plugin.
|
|
|
|
|
2023-07-11 03:24:52 +00:00
|
|
|
## Interface fields
|
|
|
|
- `paths`: A list of paths to search when loading native modules.
|
|
|
|
|
2023-07-11 02:32:59 +00:00
|
|
|
## Functions
|
|
|
|
### load(path)
|
|
|
|
Loads a module at the designated `path`.
|
|
|
|
It will throw if any error occurs.
|
|
|
|
|