From 229884ba9742065222a1a9eac02efa73f7d3a50e Mon Sep 17 00:00:00 2001 From: Sky Johnson Date: Mon, 3 Feb 2025 18:52:26 -0600 Subject: [PATCH] Add IsString and Next helpers --- wrapper.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/wrapper.go b/wrapper.go index 9ddf32c..097cd2c 100644 --- a/wrapper.go +++ b/wrapper.go @@ -185,6 +185,7 @@ func (s *State) toValueUnsafe(index int) (interface{}, error) { // Simple operations remain unchanged as they don't need stack protection func (s *State) GetType(index int) LuaType { return LuaType(C.lua_type(s.L, C.int(index))) } +func (s *State) IsString(index int) bool { return s.GetType(index) == TypeString } 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) ToBoolean(index int) bool { return C.lua_toboolean(s.L, C.int(index)) != 0 } @@ -207,6 +208,10 @@ func (s *State) PushString(str string) { C.lua_pushstring(s.L, cstr) } +func (s *State) Next(index int) bool { + return C.lua_next(s.L, C.int(index)) != 0 +} + // Helper functions func bool2int(b bool) int { if b {