CapsAdmin

Untitled

Jul 26th, 2011
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. void CLuaState::PrintStack(const char *extra)
  2. {
  3.     Print("\n%s:[", extra);
  4.  
  5.     int max = lua_gettop(L);
  6.  
  7.     for (int i = 1; i <= max; i++)
  8.     {
  9.         int type = lua_type(L, i);
  10.  
  11.         switch(type)
  12.         {
  13.         case LUA_TNONE:
  14.             Print("\t%i: [none]", i);
  15.             break;
  16.         case LUA_TNIL:
  17.             Print("\t%i: [nil]", i);
  18.             break;
  19.         case LUA_TBOOLEAN:
  20.             Print("\t%i: [boolean] %s", i, lua_toboolean(L, i) ? "true" : "false");
  21.             break;
  22.         case LUA_TNUMBER:
  23.             Print("\t%i: [number] %f", i, lua_tonumber(L, i));
  24.             break;
  25.         case LUA_TSTRING:
  26.             Print("\t%i: [string] %s", i, lua_tostring(L, i));
  27.             break;
  28.         default:
  29.             if (type == LUA_TLIGHTUSERDATA || type == LUA_TUSERDATA)
  30.             {
  31.                 Print("\t%i: [%s] %p", i, GetMetaTypeName(i), lua_topointer(L, i));
  32.             }
  33.             else
  34.             {
  35.                 Print("\t%i: [%s] %p", i, luaL_typename(L, i), lua_topointer(L, i));
  36.             }
  37.             break;
  38.         }
  39.     }
  40.  
  41.     Print("]%s\n", extra);
  42. }
Advertisement
Add Comment
Please, Sign In to add comment