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-12-22 04:03:21 +00:00
|
|
|
mlr.state.GetField(-1, "preload")
|
|
|
|
mlr.state.PushGoClosure(cluaLoader)
|
2024-07-21 15:37:08 +00:00
|
|
|
mlr.state.SetField(-2, name)
|
|
|
|
}
|