diff --git a/stepmania/src/Actor.cpp b/stepmania/src/Actor.cpp index dcd5e83846..fffdc05645 100644 --- a/stepmania/src/Actor.cpp +++ b/stepmania/src/Actor.cpp @@ -728,11 +728,26 @@ void Actor::AddRotationR( float rot ) void Actor::RunCommands( const LuaReference& cmds ) { + RunCommands2( cmds, NULL ); +} + +void Actor::RunCommands2( const LuaReference& cmds, Actor *pParent ) +{ + // function cmds.PushSelf( LUA->L ); ASSERT( !lua_isnil(LUA->L, -1) ); - this->PushSelf( LUA->L ); // 1st parameter - lua_call(LUA->L, 1, 0); // call function with 1 argument and 0 results + // 1st parameter + this->PushSelf( LUA->L ); + + // 2nd parameter + if( pParent ) + pParent->PushSelf( LUA->L ); + else + lua_pushnil( LUA->L ); + + // call function with 1 argument and 0 results + lua_call(LUA->L, 2, 0); } /* @@ -1041,6 +1056,11 @@ void Actor::AddCommand( const CString &sCmdName, apActorCommands apac ) } void Actor::PlayCommand( const CString &sCommandName ) +{ + PlayCommand2( sCommandName, NULL ); +} + +void Actor::PlayCommand2( const CString &sCommandName, Actor *pParent ) { CString sKey = sCommandName; map::const_iterator it = m_mapNameToCommands.find( sKey ); diff --git a/stepmania/src/Actor.h b/stepmania/src/Actor.h index dae02c90b2..64dec8803f 100644 --- a/stepmania/src/Actor.h +++ b/stepmania/src/Actor.h @@ -319,8 +319,11 @@ public: virtual void PushSelf( lua_State *L ); void AddCommand( const CString &sCmdName, apActorCommands apac ); virtual void PlayCommand( const CString &sCommandName ); + virtual void PlayCommand2( const CString &sCommandName, Actor *pParent ); virtual void RunCommands( const LuaReference& cmds ); + virtual void RunCommands2( const LuaReference& cmds, Actor *pParent ); void RunCommands( const apActorCommands& cmds ) { this->RunCommands( *cmds ); } // convenience + void RunCommands2( const apActorCommands& cmds, Actor *pParent ) { this->RunCommands2( *cmds, pParent ); } // convenience static float GetCommandsLengthSeconds( const LuaReference& cmds ); static float GetCommandsLengthSeconds( const apActorCommands& cmds ) { return GetCommandsLengthSeconds( *cmds ); } // convenience @@ -533,6 +536,12 @@ public: static int queuecommand( T* p, lua_State *L ) { p->QueueCommand(SArg(1)); return 0; } static int queuemessage( T* p, lua_State *L ) { p->QueueMessage(SArg(1)); return 0; } + static int GetWidth( T* p, lua_State *L ) { lua_pushnumber( L, p->GetUnzoomedWidth() ); return 1; } + static int GetHeight( T* p, lua_State *L ) { lua_pushnumber( L, p->GetUnzoomedHeight() ); return 1; } + static int GetZoom( T* p, lua_State *L ) { lua_pushnumber( L, p->GetZoom() ); return 1; } + static int GetZoomX( T* p, lua_State *L ) { lua_pushnumber( L, p->GetZoomX() ); return 1; } + + static void Register(lua_State *L) { ADD_METHOD( sleep ) ADD_METHOD( linear ) @@ -624,6 +633,12 @@ public: ADD_METHOD( playcommand ) ADD_METHOD( queuecommand ) ADD_METHOD( queuemessage ) + + ADD_METHOD( GetWidth ) + ADD_METHOD( GetHeight ) + ADD_METHOD( GetZoom ) + ADD_METHOD( GetZoomX ) + Luna::Register( L ); } }; diff --git a/stepmania/src/ActorCommands.cpp b/stepmania/src/ActorCommands.cpp index 115d9a398c..bb04b60304 100644 --- a/stepmania/src/ActorCommands.cpp +++ b/stepmania/src/ActorCommands.cpp @@ -24,7 +24,7 @@ ActorCommands::ActorCommands( const CString &sCommands ) // ostringstream s; - s << "return function(self)\n"; + s << "return function(self,parent)\n"; FOREACH_CONST( Command, cmds.v, c ) {