feat: add AchievementEntry:GetName() (#104)

This commit is contained in:
Axel Cocat
2023-03-02 00:02:33 +01:00
committed by GitHub
parent 1bfc88bb0a
commit 39c4117927
2 changed files with 33 additions and 1 deletions

View File

@@ -10,7 +10,7 @@
namespace LuaAchievement namespace LuaAchievement
{ {
/** /**
* Returns the [Achievement]s ID * Returns the [Achievement]'s ID.
* *
* @return uint32 id * @return uint32 id
*/ */
@@ -19,5 +19,36 @@ namespace LuaAchievement
Eluna::Push(L, achievement->ID); Eluna::Push(L, achievement->ID);
return 1; return 1;
} }
/**
* Returns the [Achievement]'s name.
*
* enum LocaleConstant
* {
* LOCALE_enUS = 0,
* LOCALE_koKR = 1,
* LOCALE_frFR = 2,
* LOCALE_deDE = 3,
* LOCALE_zhCN = 4,
* LOCALE_zhTW = 5,
* LOCALE_esES = 6,
* LOCALE_esMX = 7,
* LOCALE_ruRU = 8
* };
*
* @param [LocaleConstant] locale = DEFAULT_LOCALE : locale to return the [Achievement] name in
* @return string name
*/
int GetName(lua_State* L, AchievementEntry* const achievement)
{
uint8 locale = Eluna::CHECKVAL<uint8>(L, 2, DEFAULT_LOCALE);
if (locale >= TOTAL_LOCALES)
{
return luaL_argerror(L, 2, "valid LocaleConstant expected");
}
Eluna::Push(L, achievement->name[locale]);
return 1;
}
}; };
#endif #endif

View File

@@ -1355,6 +1355,7 @@ ElunaRegister<ChatHandler> ChatHandlerMethods[] =
ElunaRegister<AchievementEntry> AchievementMethods[] = ElunaRegister<AchievementEntry> AchievementMethods[] =
{ {
{ "GetId", &LuaAchievement::GetId }, { "GetId", &LuaAchievement::GetId },
{ "GetName", &LuaAchievement::GetName },
{ NULL, NULL } { NULL, NULL }
}; };