LoadFile loads a lua file
(module string, file string, data []byte)
| 29 | |
| 30 | // LoadFile loads a lua file |
| 31 | func LoadFile(module string, file string, data []byte) error { |
| 32 | pluginDef := []byte("module(\"" + module + "\", package.seeall)") |
| 33 | |
| 34 | if fn, err := L.Load(bytes.NewReader(append(pluginDef, data...)), file); err != nil { |
| 35 | return err |
| 36 | } else { |
| 37 | L.Push(fn) |
| 38 | return L.PCall(0, lua.MultRet, nil) |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | // Import allows a lua plugin to import a package |
| 43 | func Import(pkg string) *lua.LTable { |