Skip to content

Commit

Permalink
Add lua getter for Game from string
Browse files Browse the repository at this point in the history
  • Loading branch information
poco0317 committed Apr 3, 2021
1 parent 6d90f71 commit 83572df
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/Etterna/Singletons/GameManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1824,6 +1824,16 @@ class LunaGameManager : public Luna<GameManager>
GameLoop::ChangeGame(game_name, theme);
return 0;
}
static int GetGameFromString(T* p, lua_State* L)
{
std::string game = SArg(1);
const auto* g = p->StringToGame(game);
if (g == nullptr)
luaL_error(L, "GetGameFromString: Invalid Game: %s", game.c_str());
else
const_cast<Game*>(g)->PushSelf(L);
return 1;
}

LunaGameManager()
{
Expand All @@ -1833,6 +1843,7 @@ class LunaGameManager : public Luna<GameManager>
ADD_METHOD(GetStylesForGame);
ADD_METHOD(GetEnabledGames);
ADD_METHOD(SetGame);
ADD_METHOD(GetGameFromString);
};
};

Expand Down

0 comments on commit 83572df

Please sign in to comment.