diff options
| author | unwox <me@unwox.com> | 2024-09-14 15:54:27 +0600 |
|---|---|---|
| committer | unwox <me@unwox.com> | 2024-09-14 23:59:38 +0600 |
| commit | cc8d3cf4a7cd296d8c409fef5db9df138c3b238d (patch) | |
| tree | 4eae9d64ce9927e8b505fad359511bab22eccd80 /worker.go | |
| parent | 986522e417406956e83362e08adbd6a18ec904a5 (diff) | |
add luna.db.* module
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") -} |
