Skip to content

Commit

Permalink
feat(PlayerMethods): Expose the player settings methods (#125)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nyeriah authored Apr 13, 2023
1 parent a689c04 commit cea79af
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "GetRankPoints", &LuaPlayer::GetRankPoints },
{ "GetHonorLastWeekStandingPos", &LuaPlayer::GetHonorLastWeekStandingPos },
#endif
{ "GetPlayerSettingValue", &LuaPlayer::GetPlayerSettingValue },

// Setters
{ "AdvanceSkillsToMax", &LuaPlayer::AdvanceSkillsToMax },
Expand Down Expand Up @@ -779,6 +780,7 @@ ElunaRegister<Player> PlayerMethods[] =
{ "ResetHonor", &LuaPlayer::ResetHonor },
{ "ClearHonorInfo", &LuaPlayer::ClearHonorInfo },
#endif
{ "UpdatePlayerSetting", &LuaPlayer::UpdatePlayerSetting },

{ NULL, NULL }
};
Expand Down
31 changes: 31 additions & 0 deletions src/LuaEngine/PlayerMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit cea79af

Please sign in to comment.