fix RunCommandsRecursively by implementing it directly

distinguish between Run ("call this function") and Play
("look up the function with this name and call it")
This commit is contained in:
Glenn Maynard
2007-02-20 23:49:13 +00:00
parent f0c7d92fb5
commit 2fa8986ea6
4 changed files with 33 additions and 1 deletions
+18
View File
@@ -1347,6 +1347,23 @@ public:
return 1;
}
static int RunCommandsRecursively( T* p, lua_State *L )
{
luaL_checktype( L, 1, LUA_TFUNCTION );
if( !lua_istable(L, 2) && !lua_isnoneornil(L, 2) )
luaL_typerror( L, 2, "table or nil" );
LuaReference ref;
lua_pushvalue( L, 1 );
ref.SetFromStack( L );
LuaReference ParamTable;
lua_pushvalue( L, 2 );
ParamTable.SetFromStack( L );
p->RunCommandsRecursively( ref, &ParamTable );
return 0;
}
static int GetX( T* p, lua_State *L ) { lua_pushnumber( L, p->GetX() ); return 1; }
static int GetY( T* p, lua_State *L ) { lua_pushnumber( L, p->GetY() ); return 1; }
@@ -1494,6 +1511,7 @@ public:
ADD_METHOD( queuemessage );
ADD_METHOD( addcommand );
ADD_METHOD( GetCommand );
ADD_METHOD( RunCommandsRecursively );
ADD_METHOD( GetX );
ADD_METHOD( GetY );