July 2018
Beginner
202 pages
5h 42m
English
You can get the index of the top element of the Lua stack with the int lua_gettop(lua_State*) function. The value this function returns will be the index of the top element on the Lua stack.
You can set the top element (size) of the stack with lua_settop(lua_State*, int). This function returns nothing. The second argument is the element that should be the index of the new top element on the stack. This function effectively resizes the stack.
If the requested stack size with lua_settop is smaller than the previous size, all elements above the new top are simply discarded. If the requested stack size is greater than the previous one, all new elements will be filled with nil.