add flag for std libs
This commit is contained in:
parent
0756cabcaa
commit
44337fffe3
4
DOCS.md
4
DOCS.md
|
@ -3,9 +3,9 @@
|
|||
## State Management
|
||||
|
||||
### New() *State
|
||||
Creates a new Lua state with all standard libraries loaded.
|
||||
New creates a new Lua state with optional standard libraries; true if not specified
|
||||
```go
|
||||
L := luajit.New()
|
||||
L := luajit.New() // or luajit.New(false)
|
||||
defer L.Close()
|
||||
defer L.Cleanup()
|
||||
```
|
||||
|
|
|
@ -22,7 +22,7 @@ You'll need LuaJIT's development files, but don't worry - we include libraries f
|
|||
|
||||
Here's the simplest thing you can do:
|
||||
```go
|
||||
L := luajit.New()
|
||||
L := luajit.New() // pass false to not load standard libs
|
||||
defer L.Close()
|
||||
defer L.Cleanup()
|
||||
|
||||
|
|
10
wrapper.go
10
wrapper.go
|
@ -55,13 +55,17 @@ type State struct {
|
|||
L *C.lua_State
|
||||
}
|
||||
|
||||
// New creates a new Lua state with all standard libraries loaded
|
||||
func New() *State {
|
||||
// New creates a new Lua state with optional standard libraries; true if not specified
|
||||
func New(openLibs ...bool) *State {
|
||||
L := C.luaL_newstate()
|
||||
if L == nil {
|
||||
return nil
|
||||
}
|
||||
C.luaL_openlibs(L)
|
||||
|
||||
if len(openLibs) == 0 || openLibs[0] {
|
||||
C.luaL_openlibs(L)
|
||||
}
|
||||
|
||||
return &State{L: L}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user