diff --git a/wrapper.go b/wrapper.go index fe1298c..453fc70 100644 --- a/wrapper.go +++ b/wrapper.go @@ -189,6 +189,7 @@ func (s *State) IsString(index int) bool { return s.GetType(index) == TypeStr func (s *State) IsNumber(index int) bool { return s.GetType(index) == TypeNumber } func (s *State) IsFunction(index int) bool { return s.GetType(index) == TypeFunction } func (s *State) IsTable(index int) bool { return s.GetType(index) == TypeTable } +func (s *State) IsNil(index int) bool { return s.GetType(index) == TypeNil } func (s *State) ToBoolean(index int) bool { return C.lua_toboolean(s.L, C.int(index)) != 0 } func (s *State) ToNumber(index int) float64 { return float64(C.lua_tonumber(s.L, C.int(index))) } func (s *State) ToString(index int) string { @@ -327,3 +328,16 @@ func (s *State) AddPackagePath(path string) error { } return nil } + +func (s *State) Call(nargs, nresults int) error { + status := C.lua_pcall(s.L, C.int(nargs), C.int(nresults), 0) + if status != 0 { + err := &LuaError{ + Code: int(status), + Message: s.ToString(-1), + } + s.Pop(1) + return err + } + return nil +}