From cc8d3cf4a7cd296d8c409fef5db9df138c3b238d Mon Sep 17 00:00:00 2001 From: unwox Date: Sat, 14 Sep 2024 15:54:27 +0600 Subject: add luna.db.* module --- worker.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'worker.go') 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") -} -- cgit v1.2.3