[Quest API] Add GetKeyRing() to Perl/Lua (#4980)

This commit is contained in:
Alex King 2025-08-16 21:34:28 -04:00 committed by GitHub
parent 00b66ce432
commit d475428157
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 32 additions and 0 deletions

View File

@ -326,6 +326,7 @@ public:
void TraderStartTrader(const EQApplicationPacket *app);
// void TraderPriceUpdate(const EQApplicationPacket *app);
uint8 WithCustomer(uint16 NewCustomer);
std::vector<uint32> GetKeyRing() { return keyring; }
void KeyRingLoad();
bool KeyRingAdd(uint32 item_id);
bool KeyRingCheck(uint32 item_id);

View File

@ -3608,6 +3608,22 @@ void Lua_Client::EnableTitleSet(uint32 title_set) {
self->EnableTitle(title_set);
}
luabind::object Lua_Client::GetKeyRing(lua_State* L)
{
auto lua_table = luabind::newtable(L);
if (d_) {
auto self = reinterpret_cast<NativeType *>(d_);
int index = 1;
for (const uint32& item_id: self->GetKeyRing()) {
lua_table[index] = item_id;
index++;
}
}
return lua_table;
}
luabind::scope lua_register_client() {
return luabind::class_<Lua_Client, Lua_Mob>("Client")
.def(luabind::constructor<>())
@ -3838,6 +3854,7 @@ luabind::scope lua_register_client() {
.def("GetInvulnerableEnvironmentDamage", (bool(Lua_Client::*)(void))&Lua_Client::GetInvulnerableEnvironmentDamage)
.def("GetItemIDAt", (int(Lua_Client::*)(int))&Lua_Client::GetItemIDAt)
.def("GetItemCooldown", (uint32(Lua_Client::*)(uint32))&Lua_Client::GetItemCooldown)
.def("GetKeyRing", (luabind::object(Lua_Client::*)(lua_State* L))&Lua_Client::GetKeyRing)
.def("GetLDoNLosses", (int(Lua_Client::*)(void))&Lua_Client::GetLDoNLosses)
.def("GetLDoNLossesTheme", (int(Lua_Client::*)(int))&Lua_Client::GetLDoNLossesTheme)
.def("GetLDoNPointsTheme", (int(Lua_Client::*)(int))&Lua_Client::GetLDoNPointsTheme)

View File

@ -525,6 +525,7 @@ public:
bool KeyRingRemove(uint32 item_id);
bool CompleteTask(int task_id);
bool UncompleteTask(int task_id);
luabind::object GetKeyRing(lua_State* L);
// account data buckets
void SetAccountBucket(std::string bucket_name, std::string bucket_value);

View File

@ -3351,6 +3351,18 @@ bool Perl_Client_UncompleteTask(Client* self, int task_id)
return self->UncompleteTask(task_id);
}
perl::array Perl_Client_GetKeyRing(Client* self)
{
perl::array result;
const auto& v = self->GetKeyRing();
for (int i = 0; i < v.size(); ++i) {
result.push_back(v[i]);
}
return result;
}
void perl_register_client()
{
perl::interpreter perl(PERL_GET_THX);
@ -3582,6 +3594,7 @@ void perl_register_client()
package.add("GetItemCooldown", &Perl_Client_GetItemCooldown);
package.add("GetItemIDAt", &Perl_Client_GetItemIDAt);
package.add("GetItemInInventory", &Perl_Client_GetItemInInventory);
package.add("GetKeyRing", &Perl_Client_GetKeyRing);
package.add("GetLDoNLosses", &Perl_Client_GetLDoNLosses);
package.add("GetLDoNLossesTheme", &Perl_Client_GetLDoNLossesTheme);
package.add("GetLDoNPointsTheme", &Perl_Client_GetLDoNPointsTheme);