From 5e36201c4cb72f5885b5de7c98ceb6d2ad6f9a31 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Tue, 13 Feb 2007 23:58:56 +0000 Subject: [PATCH] add GetChildren --- stepmania/src/ActorFrame.cpp | 17 +++++++++++++++++ stepmania/src/ActorFrame.h | 1 + 2 files changed, 18 insertions(+) diff --git a/stepmania/src/ActorFrame.cpp b/stepmania/src/ActorFrame.cpp index 4943ae83d6..e697df89de 100644 --- a/stepmania/src/ActorFrame.cpp +++ b/stepmania/src/ActorFrame.cpp @@ -236,6 +236,17 @@ void ActorFrame::EndDraw() Actor::EndDraw(); } +void ActorFrame::PushChildrenTable( lua_State *L ) +{ + lua_newtable( L ); + FOREACH( Actor*, m_SubActors, a ) + { + LuaHelpers::Push( L, (*a)->GetName() ); + (*a)->PushSelf( L ); + lua_rawset( L, -3 ); + } +} + void ActorFrame::PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable ) { const apActorCommands *pCmd = GetCommand( sCommandName ); @@ -405,6 +416,11 @@ public: lua_pushnil( L ); return 1; } + static int GetChildren( T* p, lua_State *L ) + { + p->PushChildrenTable( L ); + return 1; + } static int GetNumChildren( T* p, lua_State *L ) { lua_pushnumber( L, p->GetNumChildren() ); return 1; } static int SetDrawByZPosition( T* p, lua_State *L ) { p->SetDrawByZPosition( BArg(1) ); return 1; } @@ -419,6 +435,7 @@ public: ADD_METHOD( SetFOV ); ADD_METHOD( vanishpoint ); ADD_METHOD( GetChild ); + ADD_METHOD( GetChildren ); ADD_METHOD( GetNumChildren ); ADD_METHOD( SetDrawByZPosition ); } diff --git a/stepmania/src/ActorFrame.h b/stepmania/src/ActorFrame.h index 365d786f0e..d37014112f 100644 --- a/stepmania/src/ActorFrame.h +++ b/stepmania/src/ActorFrame.h @@ -35,6 +35,7 @@ public: // Commands // virtual void PushSelf( lua_State *L ); + void PushChildrenTable( lua_State *L ); void PlayCommandOnChildren( const RString &sCommandName, const LuaReference *pParamTable = NULL ); void PlayCommandOnLeaves( const RString &sCommandName, const LuaReference *pParamTable = NULL ); virtual void RunCommandsOnChildren( const LuaReference& cmds, const LuaReference *pParamTable = NULL ); /* but not on self */