[LifeMeterBattery] Added ChangeLives(int) Lua binding.

This commit is contained in:
AJ Kelly
2011-06-13 13:32:28 -05:00
parent bd9c58b37e
commit d8e1296b5b
3 changed files with 12 additions and 1 deletions
+1
View File
@@ -10,6 +10,7 @@ StepMania 5.0 Preview 2 | 20110???
2011/06/13 2011/06/13
---------- ----------
* [LifeMeterBattery] Added ChangeLives(int) Lua binding. [AJ]
* [LifeMeterBattery] Added DangerThreshold metric. [AJ] * [LifeMeterBattery] Added DangerThreshold metric. [AJ]
* [LifeMeterBattery] Added some important metrics. [AJ] * [LifeMeterBattery] Added some important metrics. [AJ]
* MinScoreToKeepLife='TapNoteScore_*' - any score below this = loss of life. * MinScoreToKeepLife='TapNoteScore_*' - any score below this = loss of life.
+10 -1
View File
@@ -137,6 +137,14 @@ void LifeMeterBattery::AddLives( int iLives )
m_fBatteryBlinkTime = 0; m_fBatteryBlinkTime = 0;
} }
void LifeMeterBattery::ChangeLives(int iLifeDiff)
{
if( iLifeDiff < 0 )
SubtractLives( abs(iLifeDiff) );
else if( iLifeDiff > 0 )
AddLives(iLifeDiff);
}
void LifeMeterBattery::ChangeLife( TapNoteScore score ) void LifeMeterBattery::ChangeLife( TapNoteScore score )
{ {
if( m_iLivesLeft == 0 ) if( m_iLivesLeft == 0 )
@@ -254,13 +262,14 @@ class LunaLifeMeterBattery: public Luna<LifeMeterBattery>
{ {
public: public:
static int GetLivesLeft( T* p, lua_State *L ) { lua_pushnumber( L, p->GetLivesLeft() ); return 1; } static int GetLivesLeft( T* p, lua_State *L ) { lua_pushnumber( L, p->GetLivesLeft() ); return 1; }
// is this right? wtf -q2x
static int GetTotalLives( T* p, lua_State *L ) { lua_pushnumber( L, GAMESTATE->m_SongOptions.GetSong().m_iBatteryLives ); return 1; } static int GetTotalLives( T* p, lua_State *L ) { lua_pushnumber( L, GAMESTATE->m_SongOptions.GetSong().m_iBatteryLives ); return 1; }
static int ChangeLives( T* p, lua_State *L ) { p->ChangeLives(IArg(1)); return 0; }
LunaLifeMeterBattery() LunaLifeMeterBattery()
{ {
ADD_METHOD( GetLivesLeft ); ADD_METHOD( GetLivesLeft );
ADD_METHOD( GetTotalLives ); ADD_METHOD( GetTotalLives );
ADD_METHOD( ChangeLives );
} }
}; };
+1
View File
@@ -32,6 +32,7 @@ public:
void Refresh(); void Refresh();
int GetLivesLeft() { return m_iLivesLeft; } int GetLivesLeft() { return m_iLivesLeft; }
void ChangeLives(int iLifeDiff);
// Lua // Lua
virtual void PushSelf( lua_State *L ); virtual void PushSelf( lua_State *L );