summaryrefslogtreecommitdiff
path: root/worker.go
diff options
context:
space:
mode:
Diffstat (limited to 'worker.go')
-rw-r--r--worker.go17
1 files changed, 9 insertions, 8 deletions
diff --git a/worker.go b/worker.go
index b4cae12..2df98a0 100644
--- a/worker.go
+++ b/worker.go
@@ -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")
-}