fix: attempt some small fixes for loading modules

midnight-edition
sammyette 2024-07-26 17:58:25 -04:00
parent 2eb1ea398f
commit d6eb92f321
Signed by: sammyette
GPG Key ID: 904FC49417B44DCD
5 changed files with 9 additions and 3 deletions

1
api.go
View File

@ -37,6 +37,7 @@ import (
var hshMod *moonlight.Table
func hilbishLoader(mlr *moonlight.Runtime) moonlight.Value {
println("hilbish loader called")
var exports = map[string]moonlight.Export{
"alias": {hlalias, 2, false},
"appendPath": {hlappendPath, 1, false},

2
lua.go
View File

@ -52,7 +52,7 @@ func luaInit() {
*/
// Add more paths that Lua can require from
_, err := l.DoString("package.path = package.path .. " + requirePaths)
_, err := l.DoString("print(type(hilbish)); package.path = package.path .. " + requirePaths)
if err != nil {
fmt.Fprintln(os.Stderr, err)
fmt.Fprintln(os.Stderr, "Could not add Hilbish require paths! Libraries will be missing. This shouldn't happen.")

View File

@ -15,7 +15,7 @@ func (mlr *Runtime) LoadLibrary(ldr Loader, name string) {
}
mlr.state.GetGlobal("package")
mlr.state.GetField(-1, "preload")
mlr.state.GetField(-1, "loaded")
mlr.state.PushGoFunction(cluaLoader)
mlr.state.SetField(-2, name)
}

View File

@ -41,3 +41,7 @@ func ToTable(v Value) *Table {
func TryTable(v Value) (*Table, bool) {
return nil, false
}
func (t *Table) setRefIdx(mlr *Runtime, i idx) {
t.refIdx = mlr.state.Ref(i)
}

View File

@ -8,5 +8,6 @@ func (mlr *Runtime) DoString(code string) (Value, error) {
}
func (mlr *Runtime) DoFile(filename string) error {
return mlr.state.DoFile(filename)
//return mlr.state.DoFile(filename)
return nil
}