feat(PlayerMethods): Expose the player settings methods (#125)

This commit is contained in:
Skjalf
2023-04-13 19:41:54 -03:00
committed by GitHub
parent a689c043a7
commit cea79af0b1
3 changed files with 34 additions and 0 deletions

View File

@@ -95,6 +95,7 @@ Eluna API for AC:
- Added `Player:GetXP()`: https://github.com/azerothcore/mod-eluna/pull/77
- Added `Player:GetAchievementCriteriaProgress()`: https://github.com/azerothcore/mod-eluna/pull/78
- Added vendor entry as argument to `Player:SendListInventory(object, vendorentry)`: https://github.com/azerothcore/mod-eluna/pull/48
- Added `Player:GetPlayerSettingValue()` and `Player:UpdatePlayerSetting()`: https://github.com/azerothcore/mod-eluna/pull/125
### Group
- Added `Group:GetGroupType()`: https://github.com/azerothcore/mod-eluna/pull/82

View File

@@ -543,6 +543,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetRankPoints", &LuaPlayer::GetRankPoints },
{ "GetHonorLastWeekStandingPos", &LuaPlayer::GetHonorLastWeekStandingPos },
#endif
{ "GetPlayerSettingValue", &LuaPlayer::GetPlayerSettingValue },
// Setters
{ "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax },
@@ -779,6 +780,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "ResetHonor", &LuaPlayer::ResetHonor },
{ "ClearHonorInfo", &LuaPlayer::ClearHonorInfo },
#endif
{ "UpdatePlayerSetting", &LuaPlayer::UpdatePlayerSetting },
{ NULL, NULL }
};

View File

@@ -4168,6 +4168,37 @@ namespace LuaPlayer
}
#endif
/**
* Sets a setting value for the [Player]
*
* @param string source
* @param uint32 index
* @param uint32 value
*/
int UpdatePlayerSetting(lua_State* L, Player* player)
{
std::string source = Eluna::CHECKVAL<std::string>(L, 2);
uint32 index = Eluna::CHECKVAL<uint32>(L, 3);
uint32 value = Eluna::CHECKVAL<uint32>(L, 4);
player->UpdatePlayerSetting(source, index, value);
return 0;
}
/**
* Gets a setting value for the [Player]
*
* @param string source
* @param uint32 index
*/
int GetPlayerSettingValue(lua_State* L, Player* player)
{
std::string source = Eluna::CHECKVAL<std::string>(L, 2);
uint32 index = Eluna::CHECKVAL<uint32>(L, 3);
uint32 value = player->GetPlayerSetting(source, index).value;
Eluna::Push(L, value);
return 1;
}
/*int BindToInstance(lua_State* L, Player* player)
{
player->BindToInstance();