NewStateEx creates a new Lua state. It calls NewState and then sets a panic function that prints an error message to the standard error output in case of fatal errors. Returns the new state.
()
| 534 | // |
| 535 | // Returns the new state. |
| 536 | func NewStateEx() *State { |
| 537 | l := NewState() |
| 538 | if l != nil { |
| 539 | _ = AtPanic(l, func(l *State) int { |
| 540 | s, _ := l.ToString(-1) |
| 541 | fmt.Fprintf(os.Stderr, "PANIC: unprotected error in call to Lua API (%s)\n", s) |
| 542 | return 0 |
| 543 | }) |
| 544 | } |
| 545 | return l |
| 546 | } |
| 547 | |
| 548 | func LengthEx(l *State, index int) int { |
| 549 | l.Length(index) |