diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index aa0a4d1b96..4e3dae3bbc 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -2627,6 +2627,16 @@ Song *ScreenGameplay::GetNextCourseSong() const return m_apSongsQueue[iPlaySongIndex]; } +PlayerInfo *ScreenGameplay::GetPlayerInfo( PlayerNumber pn ) +{ + FOREACH_EnabledPlayerNumberInfo( m_vPlayerInfo, pi ) + { + if( pi->m_pn == pn ) + return &*pi; + } + return NULL; +} + void ScreenGameplay::SaveReplay() { FOREACH_HumanPlayer( pn ) @@ -2677,15 +2687,41 @@ class LunaScreenGameplay: public Luna public: static int GetNextCourseSong( T* p, lua_State *L ) { p->GetNextCourseSong()->PushSelf(L); return 1; } static int Center1Player( T* p, lua_State *L ) { lua_pushboolean( L, p->Center1Player() ); return 1; } + static int GetPlayerInfo( T* p, lua_State *L ) + { + PlayerNumber pn = Enum::Check( L, 1 ); + + PlayerInfo *pInfo = p->GetPlayerInfo(pn); + if( pInfo == NULL ) + return 0; + + pInfo->PushSelf( L ); + return 1; + } LunaScreenGameplay() { ADD_METHOD( GetNextCourseSong ); ADD_METHOD( Center1Player ); + ADD_METHOD( GetPlayerInfo ); } }; LUA_REGISTER_DERIVED_CLASS( ScreenGameplay, ScreenWithMenuElements ) + + +class LunaPlayerInfo: public Luna +{ +public: + static int GetLifeMeter( T* p, lua_State *L ) { p->m_pLifeMeter->PushSelf(L); return 1; } + + LunaPlayerInfo() + { + ADD_METHOD( GetLifeMeter ); + } +}; + +LUA_REGISTER_CLASS( PlayerInfo ) // lua end /* diff --git a/stepmania/src/ScreenGameplay.h b/stepmania/src/ScreenGameplay.h index a83c9e0f3e..c34a8b5e0e 100644 --- a/stepmania/src/ScreenGameplay.h +++ b/stepmania/src/ScreenGameplay.h @@ -64,6 +64,11 @@ public: return PlayerNumberToString( m_pn ); } + // + // Lua + // + virtual void PushSelf( lua_State *L ); + PlayerNumber m_pn; MultiPlayer m_mp; bool m_bIsDummy; @@ -120,6 +125,7 @@ public: // virtual void PushSelf( lua_State *L ); Song *GetNextCourseSong() const; + PlayerInfo *GetPlayerInfo( PlayerNumber pn ); protected: virtual bool GenericTweenOn() const { return true; }