added type() top-level Lua function like the one in the basic package
git-svn-id: svn://anubis/anaglym/trunk@228 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
65ee4ccab2
commit
ffe587c0a3
50
ag.cc
50
ag.cc
@ -58,6 +58,7 @@ namespace ag
|
||||
// { "sleep", sleep },
|
||||
{ "startFrame", startFrame },
|
||||
{ "startList", startList },
|
||||
{ "type", type },
|
||||
{ "clearWorld", clearWorld },
|
||||
|
||||
/* managed object functions */
|
||||
@ -78,6 +79,8 @@ namespace ag
|
||||
luaL_loadstring(L,
|
||||
"next = ag.next\n"
|
||||
|
||||
"type = ag.type\n"
|
||||
|
||||
"pairs = function(table)\n"
|
||||
" return next, table, nil\n"
|
||||
"end\n"
|
||||
@ -94,10 +97,10 @@ namespace ag
|
||||
" return iter_func, table, 0\n"
|
||||
"end\n"
|
||||
|
||||
"ag.createAMotor = function()\n"
|
||||
"ag.createAMotor = function(obj1, obj2, axis1, axis2, axis3)\n"
|
||||
"end\n"
|
||||
);
|
||||
int s = lua_pcall(L, 0, 0, 0);
|
||||
lua_pcall(L, 0, 0, 0);
|
||||
}
|
||||
|
||||
static void print_val(lua_State * L, int index)
|
||||
@ -191,6 +194,49 @@ namespace ag
|
||||
}
|
||||
}
|
||||
|
||||
int type(lua_State * L)
|
||||
{
|
||||
int argc = lua_gettop(L);
|
||||
if (argc == 1)
|
||||
{
|
||||
int type = lua_type(L, 1);
|
||||
switch (type)
|
||||
{
|
||||
case LUA_TNUMBER:
|
||||
lua_pushstring(L, "number");
|
||||
break;
|
||||
case LUA_TBOOLEAN:
|
||||
lua_pushstring(L, "boolean");
|
||||
break;
|
||||
case LUA_TSTRING:
|
||||
lua_pushstring(L, "string");
|
||||
break;
|
||||
case LUA_TTABLE:
|
||||
lua_pushstring(L, "table");
|
||||
break;
|
||||
case LUA_TFUNCTION:
|
||||
lua_pushstring(L, "function");
|
||||
break;
|
||||
case LUA_TTHREAD:
|
||||
lua_pushstring(L, "thread");
|
||||
break;
|
||||
case LUA_TUSERDATA:
|
||||
case LUA_TLIGHTUSERDATA:
|
||||
lua_pushstring(L, "userdata");
|
||||
break;
|
||||
case LUA_TNIL:
|
||||
default:
|
||||
lua_pushstring(L, "nil");
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
lua_pushstring(L, "nil");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void createLuaObject(lua_State * L, int id)
|
||||
{
|
||||
lua_newtable(L);
|
||||
|
Loading…
x
Reference in New Issue
Block a user