2024-07-21 15:37:08 +00:00
|
|
|
//go:build midnight
|
|
|
|
package moonlight
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/aarzilli/golua/lua"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Loader func(*Runtime) Value
|
|
|
|
|
|
|
|
func (mlr *Runtime) LoadLibrary(ldr Loader, name string) {
|
|
|
|
cluaLoader := func (L *lua.State) int {
|
|
|
|
mlr.pushToState(ldr(mlr))
|
|
|
|
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
|
|
|
mlr.state.GetGlobal("package")
|
2024-07-26 21:58:25 +00:00
|
|
|
mlr.state.GetField(-1, "loaded")
|
2024-07-21 15:37:08 +00:00
|
|
|
mlr.state.PushGoFunction(cluaLoader)
|
|
|
|
mlr.state.SetField(-2, name)
|
|
|
|
}
|