using UniLua; class Example { static void Main() { LuaState lua = new LuaState(); lua.DoString("a = 123; b = 'Hello';"); int top = lua.GetTop(); // Get the index of the top of the stack Console.WriteLine("Stack top index: " + top); // Output: 2 } }
using UniLua; class Example { static void Main() { LuaState lua = new LuaState(); lua.PushNumber(10); lua.PushString("Hello"); int top = lua.GetTop(); // Get the index of the top of the stack Console.WriteLine("Stack top index: " + top); // Output: 2 } }In this example, we create a new LuaState and manually push two values onto the stack. We then use the lua_gettop() function to get the index of the top of the stack, which is 2. Package Library: UniLua