diff options
Diffstat (limited to 'worker.go')
| -rw-r--r-- | worker.go | 17 |
1 files changed, 9 insertions, 8 deletions
@@ -64,8 +64,15 @@ func (w *Worker) Start(filename string, module map[string]any) error { } w.lua.Start() defer w.lua.RestoreStackFunc()() - w.initLunaModule(module) - err := w.lua.Require(filename) + + // registers the module in the Lua context + err := w.lua.PushObject(module) + if err != nil { + return err + } + w.lua.SetGlobal("luna") + + err = w.lua.Require(filename) if err != nil { return err } @@ -206,9 +213,3 @@ func (w *Worker) Stop() { func (w *Worker) HasSameLua(l *Lua) bool { return w.lua == l } - -// initLunaModule registers the module in the Lua context. -func (w *Worker) initLunaModule(module map[string]any) { - w.lua.PushObject(module) - w.lua.SetGlobal("luna") -} |
