diff --git a/Docs/Changelog_sm-ssc.txt b/Docs/Changelog_sm-ssc.txt index d913d09145..4c66657a84 100644 --- a/Docs/Changelog_sm-ssc.txt +++ b/Docs/Changelog_sm-ssc.txt @@ -16,6 +16,9 @@ sm-ssc v1.2 | 201012xx 20101218 -------- * [MusicWheelItem] Add OverPart. [freem] +* [Profile] SetCharacter(sCharID) Lua binding added. [freem] +* [GameState] GetCharacter(PlayerNumber) and SetCharacter(PlayerNumber,sCharID) + Lua bindings added. [freem] 20101217 -------- diff --git a/src/GameState.cpp b/src/GameState.cpp index 7e89e385f3..8194bbbeed 100644 --- a/src/GameState.cpp +++ b/src/GameState.cpp @@ -2448,6 +2448,13 @@ public: DEFINE_METHOD( GetCurMusicSeconds, m_fMusicSeconds ) DEFINE_METHOD( GetWorkoutGoalComplete, m_bWorkoutGoalComplete ) + static int GetCharacter( T* p, lua_State *L ) { p->m_pCurCharacters[Enum::Check(L, 1)]->PushSelf(L); return 1; } + static int SetCharacter( T* p, lua_State *L ){ + Character* c = CHARMAN->GetCharacterFromID(SArg(2)); + if (c) + p->m_pCurCharacters[Enum::Check(L, 1)] = c; + return 0; + } LunaGameState() { @@ -2543,6 +2550,8 @@ public: ADD_METHOD( UnjoinPlayer ); ADD_METHOD( GetSongPercent ); ADD_METHOD( GetCurMusicSeconds ); + ADD_METHOD( GetCharacter ); + ADD_METHOD( SetCharacter ); } }; diff --git a/src/Profile.cpp b/src/Profile.cpp index fd686eaa91..35c52c7377 100644 --- a/src/Profile.cpp +++ b/src/Profile.cpp @@ -201,6 +201,12 @@ Character *Profile::GetCharacter() const return CHARMAN->GetDefaultCharacter(); } +void Profile::SetCharacter(const RString sCharacterID) +{ + if(CHARMAN->GetCharacterFromID(sCharacterID)) + m_sCharacterID = sCharacterID; +} + static RString FormatCalories( float fCals ) { return Commify((int)fCals) + " Cal"; @@ -1957,6 +1963,7 @@ public: } static int GetCharacter( T* p, lua_State *L ) { p->GetCharacter()->PushSelf(L); return 1; } + static int SetCharacter( T* p, lua_State *L ) { p->SetCharacter(SArg(1)); return 0; } static int GetWeightPounds( T* p, lua_State *L ) { lua_pushnumber(L, p->m_iWeightPounds ); return 1; } static int SetWeightPounds( T* p, lua_State *L ) { p->m_iWeightPounds = IArg(1); return 0; } static int GetGoalType( T* p, lua_State *L ) { lua_pushnumber(L, p->m_GoalType ); return 1; } @@ -2030,6 +2037,7 @@ public: ADD_METHOD( GetDisplayName ); ADD_METHOD( GetHighScoreList ); ADD_METHOD( GetCharacter ); + ADD_METHOD( SetCharacter ); ADD_METHOD( GetWeightPounds ); ADD_METHOD( SetWeightPounds ); ADD_METHOD( GetGoalType ); diff --git a/src/Profile.h b/src/Profile.h index aa998d3825..9809c68467 100644 --- a/src/Profile.h +++ b/src/Profile.h @@ -67,6 +67,7 @@ public: // smart accessors RString GetDisplayNameOrHighScoreName() const; Character *GetCharacter() const; + void SetCharacter(const RString sCharacterID); RString GetDisplayTotalCaloriesBurned() const; // remove me and use Lua instead RString GetDisplayTotalCaloriesBurnedToday() const; // remove me and use Lua instead int GetCalculatedWeightPounds() const; // returns a default value if m_iWeightPounds isn't set