added ag::object::getObject() helper method, stub getPosition() and setPosition() methods
git-svn-id: svn://anubis/anaglym/trunk@42 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
parent
95c13516ef
commit
99a8835954
54
ag.cc
54
ag.cc
@ -125,7 +125,11 @@ namespace ag
|
|||||||
lua_setfield(L, -2, "draw");
|
lua_setfield(L, -2, "draw");
|
||||||
if (physpath != "")
|
if (physpath != "")
|
||||||
{
|
{
|
||||||
g_engine->getObject(id)->loadPhy(physpath);
|
Engine::Object * obj = g_engine->getObject(id);
|
||||||
|
if (obj != NULL)
|
||||||
|
{
|
||||||
|
obj->loadPhy(physpath);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -197,24 +201,58 @@ namespace ag
|
|||||||
|
|
||||||
namespace object
|
namespace object
|
||||||
{
|
{
|
||||||
|
static Engine::Object * getObject(lua_State * L, int index)
|
||||||
|
{
|
||||||
|
Engine::Object * ret = NULL;
|
||||||
|
|
||||||
|
lua_getfield(L, index, "id");
|
||||||
|
if (lua_type(L, -1) == LUA_TNUMBER)
|
||||||
|
{
|
||||||
|
int id = lua_tointeger(L, -1);
|
||||||
|
ret = g_engine->getObject(id);
|
||||||
|
}
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
int draw(lua_State * L)
|
int draw(lua_State * L)
|
||||||
{
|
{
|
||||||
int argc = lua_gettop(L);
|
int argc = lua_gettop(L);
|
||||||
if (argc == 1 && lua_type(L, -1) == LUA_TTABLE)
|
if (argc == 1 && lua_type(L, -1) == LUA_TTABLE)
|
||||||
{
|
{
|
||||||
lua_getfield(L, -1, "id");
|
Engine::Object * obj = getObject(L, -1);
|
||||||
if (lua_type(L, -1) == LUA_TNUMBER)
|
|
||||||
{
|
|
||||||
int id = lua_tointeger(L, -1);
|
|
||||||
Engine::Object * obj = g_engine->getObject(id);
|
|
||||||
if (obj != NULL)
|
if (obj != NULL)
|
||||||
{
|
{
|
||||||
obj->draw();
|
obj->draw();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
lua_pop(L, 1);
|
|
||||||
}
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int setPosition(lua_State * L)
|
||||||
|
{
|
||||||
|
int argc = lua_gettop(L);
|
||||||
|
|
||||||
|
if (argc == 4)
|
||||||
|
{
|
||||||
|
double position[3];
|
||||||
|
for (int i = 0; i < 3; i++)
|
||||||
|
{
|
||||||
|
int type = lua_type(L, i);
|
||||||
|
if (type == LUA_TNUMBER || type == LUA_TSTRING)
|
||||||
|
{
|
||||||
|
position[i] = lua_tonumber(L, i + 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getPosition(lua_State * L)
|
||||||
|
{
|
||||||
|
return 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user