diff --git a/Docs/Luadoc/Lua.xml b/Docs/Luadoc/Lua.xml index 994dd0d681..691ce12ff5 100644 --- a/Docs/Luadoc/Lua.xml +++ b/Docs/Luadoc/Lua.xml @@ -1107,6 +1107,7 @@ + @@ -1118,6 +1119,7 @@ + diff --git a/Docs/Luadoc/LuaDocumentation.xml b/Docs/Luadoc/LuaDocumentation.xml index d40e06f3b2..13042df69c 100644 --- a/Docs/Luadoc/LuaDocumentation.xml +++ b/Docs/Luadoc/LuaDocumentation.xml @@ -3217,6 +3217,9 @@ save yourself some time, copy this for undocumented things: Returns the number of calories burned. + + Returns a table of all the combos. Each entry in the table is a table containing the StartSecond, SizeSeconds, Count, Rollover, StageCount, and IsZero information for that combo. + Returns the current possible maximum score. @@ -3250,6 +3253,11 @@ save yourself some time, copy this for undocumented things: Returns the score needed to pass the lesson. + + Returns table of samples of the life record from 0 to last_second. + 'samples' determines the size of the table. 'samples' defaults to 100 + if not specified. + Returns the player's life remaining seconds. diff --git a/src/PlayerStageStats.cpp b/src/PlayerStageStats.cpp index 59ac8dc5fb..8bcc3b9de6 100644 --- a/src/PlayerStageStats.cpp +++ b/src/PlayerStageStats.cpp @@ -741,6 +741,58 @@ public: } return 1; } + static int GetComboList( T* p, lua_State *L ) + { + lua_createtable(L, p->m_ComboList.size(), 0); + for( size_t i= 0; i < p->m_ComboList.size(); ++i) + { + lua_createtable(L, 0, 6); + lua_pushstring(L, "StartSecond"); + lua_pushnumber(L, p->m_ComboList[i].m_fStartSecond); + lua_rawset(L, -3); + lua_pushstring(L, "SizeSeconds"); + lua_pushnumber(L, p->m_ComboList[i].m_fSizeSeconds); + lua_rawset(L, -3); + lua_pushstring(L, "Count"); + lua_pushnumber(L, p->m_ComboList[i].m_cnt); + lua_rawset(L, -3); + lua_pushstring(L, "Rollover"); + lua_pushnumber(L, p->m_ComboList[i].m_rollover); + lua_rawset(L, -3); + lua_pushstring(L, "StageCount"); + lua_pushnumber(L, p->m_ComboList[i].GetStageCnt()); + lua_rawset(L, -3); + lua_pushstring(L, "IsZero"); + lua_pushnumber(L, p->m_ComboList[i].IsZero()); + lua_rawset(L, -3); + lua_rawseti(L, -2, i+1); + } + return 1; + } + static int GetLifeRecord( T* p, lua_State *L ) + { + float last_second= FArg(1); + int samples= 100; + if (lua_gettop(L) >= 2 && !lua_isnil(L,2)) + { + samples= IArg(2); + if(samples <= 0) + { + LOG->Trace("PlayerStageStats:GetLifeRecord requires an integer greater than 0. Defaulting to 100."); + samples= 100; + } + } + lua_createtable(L, samples, 0); + for(int i= 0; i < samples; ++i) + { + // The scale from range is [0, samples-1] because that is i's range. + float from= SCALE(i, 0, (float)samples-1.0f, 0.0f, last_second); + float curr= p->GetLifeRecordLerpAt(from); + lua_pushnumber(L, curr); + lua_rawseti(L, -2, i+1); + } + return 1; + } static int GetRadarPossible( T* p, lua_State *L ) { p->m_radarPossible.PushSelf(L); return 1; } static int GetRadarActual( T* p, lua_State *L ) { p->m_radarActual.PushSelf(L); return 1; } @@ -800,6 +852,8 @@ public: ADD_METHOD( IsDisqualified ); ADD_METHOD( GetPlayedSteps ); ADD_METHOD( GetPossibleSteps ); + ADD_METHOD( GetComboList ); + ADD_METHOD( GetLifeRecord ); ADD_METHOD( GetAliveSeconds ); ADD_METHOD( GetPercentageOfTaps ); ADD_METHOD( GetRadarActual ); diff --git a/src/PlayerStageStats.h b/src/PlayerStageStats.h index f59d420464..4794717ffe 100644 --- a/src/PlayerStageStats.h +++ b/src/PlayerStageStats.h @@ -99,6 +99,7 @@ public: struct Combo_t { + // Update GetComboList in PlayerStageStats.cpp when adding new members that should be visible from the Lua side. /** * @brief The start time of the combo. *