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
|
## State Management
|
||||||
|
|
||||||
### New() *State
|
### 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
|
```go
|
||||||
L := luajit.New()
|
L := luajit.New() // or luajit.New(false)
|
||||||
defer L.Close()
|
defer L.Close()
|
||||||
defer L.Cleanup()
|
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:
|
Here's the simplest thing you can do:
|
||||||
```go
|
```go
|
||||||
L := luajit.New()
|
L := luajit.New() // pass false to not load standard libs
|
||||||
defer L.Close()
|
defer L.Close()
|
||||||
defer L.Cleanup()
|
defer L.Cleanup()
|
||||||
|
|
||||||
|
|
|
@ -55,13 +55,17 @@ type State struct {
|
||||||
L *C.lua_State
|
L *C.lua_State
|
||||||
}
|
}
|
||||||
|
|
||||||
// New creates a new Lua state with all standard libraries loaded
|
// New creates a new Lua state with optional standard libraries; true if not specified
|
||||||
func New() *State {
|
func New(openLibs ...bool) *State {
|
||||||
L := C.luaL_newstate()
|
L := C.luaL_newstate()
|
||||||
if L == nil {
|
if L == nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if len(openLibs) == 0 || openLibs[0] {
|
||||||
C.luaL_openlibs(L)
|
C.luaL_openlibs(L)
|
||||||
|
}
|
||||||
|
|
||||||
return &State{L: L}
|
return &State{L: L}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user