Hilbish/moonlight/loader_clua.go

22 lines
398 B
Go
Raw Normal View History

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")
mlr.state.GetField(-1, "loaded")
2024-07-21 15:37:08 +00:00
mlr.state.PushGoFunction(cluaLoader)
mlr.state.SetField(-2, name)
}