registering lua function setTextureScale for objects

git-svn-id: svn://anubis/anaglym/trunk@220 99a6e188-d820-4881-8870-2d33a10e2619
This commit is contained in:
Josh Holtrop 2009-12-16 03:21:47 +00:00
parent fd4b6b27c8
commit de49999c88
3 changed files with 13 additions and 13 deletions

View File

@ -925,20 +925,17 @@ void Engine::mouse_motion_event(int x, int y, int xrel, int yrel)
void Engine::checkForFunctionFull(const std::string & lua_fn_name,
const std::string & event_name, bool & presentFlag)
{
if (!presentFlag) /* only look for events we do not have a handler for */
lua_getfield(m_luaState, LUA_GLOBALSINDEX, lua_fn_name.c_str());
if (lua_isfunction(m_luaState, -1))
{
lua_getfield(m_luaState, LUA_GLOBALSINDEX, lua_fn_name.c_str());
if (lua_isfunction(m_luaState, -1))
{
lua_setfield(m_luaState, LUA_GLOBALSINDEX,
(AG_EVENT_PREFIX + event_name).c_str());
presentFlag = true;
}
else
{
lua_pop(m_luaState, 1);
presentFlag = false;
}
lua_setfield(m_luaState, LUA_GLOBALSINDEX,
(AG_EVENT_PREFIX + event_name).c_str());
presentFlag = true;
}
else
{
lua_pop(m_luaState, 1);
presentFlag = false;
}
}

View File

@ -71,6 +71,7 @@ class Engine
void setTextureScale(float scale)
{
m_texture_scale = scale;
render();
}
void draw();
dReal getMass() { return m_ode_object->getMass(); }

2
ag.cc
View File

@ -169,6 +169,8 @@ namespace ag
lua_setfield(L, -2, "setColor");
lua_pushcfunction(L, object::setTexture);
lua_setfield(L, -2, "setTexture");
lua_pushcfunction(L, object::setTextureScale);
lua_setfield(L, -2, "setTextureScale");
lua_pushcfunction(L, object::setMass);
lua_setfield(L, -2, "setMass");
lua_pushcfunction(L, object::getMass);