2
2
mirror of https://github.com/Hilbis/Hilbish synced 2025-07-01 16:52:03 +00:00
Hilbish/moonlight/loader_clua.go
sammyette 0a0f2e2c38
fix: implement go lua library loading
and remove debug symbol stripping flags when building
on midnight
2024-12-22 01:09:24 -04:00

22 lines
398 B
Go

//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, "preload")
mlr.state.PushGoClosure(cluaLoader)
mlr.state.SetField(-2, name)
}