lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I've been reluctant to buy that because I thought it only covered the basics of Lua coding, like, not the C API... But now that you say it does, I have some questions:

1) What does it cover the most? I already know most of the "plain Lua" part of it, I've made 2 games for the PSP Lua Player.
2) Is it the best book about it out there?

And back to the subject, it prints out just a number '1'... Looking at the code, it seems it can either be a userdata or a table, so it's a userdata... But what does the '1' mean?

Thanks for everything, Mr. Smith!

Wesley Smith wrote:
I would highly recommend picking up programming in Lua.  It has all
kind of stuff in there like this.  You will learn Lua much faster!

int stackDump(lua_State *L)
{
	int i;
	int top = lua_gettop(L);
	
	printf("stack dump %d:\n", top);
	for(i=top; i >= 1; i--) {
		int t = lua_type(L, i);
		
		switch(t)
		{
			case LUA_TSTRING:
					printf("%d \t'%s' string\n", i, lua_tostring(L, i));
					break;
					
			case LUA_TBOOLEAN:
					printf(lua_toboolean(L, i) ? "\ttrue\n" : "\tfalse\n");
					break;
					
			case LUA_TNUMBER:
					printf("%d \t'%f' number\n", i, lua_tonumber(L, i));
					break;
			
			case LUA_TLIGHTUSERDATA:
					printf("%d \t'%x'\n", i, lua_touserdata(L, i));
					break;
					
			case LUA_TUSERDATA:
					printf("%d ", i);
					lua_getglobal(L, "print");
					lua_pushvalue(L, i);
					lua_call(L, 1, 0);
					//printf("%d \t'%x %s'\n", i, lua_touserdata(L, i), T::name);
					break;
					
			case LUA_TFUNCTION:
					printf("%d \t'func: %x'\n", i, lua_tocfunction(L, i));
					break;
			
			case LUA_TTABLE:
					printf("%d ", i);
					lua_getglobal(L, "print");
					lua_pushvalue(L, i);
					lua_call(L, 1, 0);
					break;
			
			default:
					printf("%d \t'%s'\n", i, lua_typename(L, t));
					break;
		}
	}
	
	return 0;
}