Skip to content

Commit

Permalink
Improve lua access to changing player on net eval
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Dec 4, 2018
1 parent 6a8db24 commit cd1cb97
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Themes/Til Death/BGAnimations/MPscoreboard.lua
Expand Up @@ -13,7 +13,7 @@ local function input(event)
if event.type == "InputEventType_Release" then
for i = 1, #multiscores do
if isOver(scoreBoard:GetChild(i):GetChild("mouseOver")) then
SCREENMAN:GetTopScreen():SetCurrentPlayer(i)
SCREENMAN:GetTopScreen():SetCurrentPlayerByName(multiscores[i].user)
scoreBoard:GetChild(i):GetChild("grade"):visible(
not scoreBoard:GetChild(i):GetChild("grade"):GetVisible()
)
Expand Down
19 changes: 19 additions & 0 deletions src/ScreenNetEvaluation.cpp
Expand Up @@ -163,13 +163,32 @@ class LunaScreenNetEvaluation : public Luna<ScreenNetEvaluation>
p->UpdateStats();
return 0;
}
static int SetCurrentPlayerByName(T* p, lua_State* L)
{
int theNumber = 0;
RString given = SArg(1);
for (size_t i = 0; i < NSMAN->m_EvalPlayerData.size(); i++)
{
EndOfGame_PlayerData& pd = NSMAN->m_EvalPlayerData[i];
RString name = pd.nameStr;
name.MakeLower();
if (name == given)
{
p->m_iCurrentPlayer = (int)i;
p->UpdateStats();
break;
}
}
return 0;
}
LunaScreenNetEvaluation()
{
ADD_METHOD(GetNumActivePlayers);
ADD_METHOD(GetHighScore);
ADD_METHOD(GetOptions);
ADD_METHOD(GetCurrentPlayer);
ADD_METHOD(SetCurrentPlayer);
ADD_METHOD(SetCurrentPlayerByName);
}
};

Expand Down

0 comments on commit cd1cb97

Please sign in to comment.