mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-18 20:48:26 +00:00
[Quest API] Add client->SummonBaggedItems(bag_item_id, bag_items_ref) to Perl/Lua.
Alternative apis using arrays of hash items for EQEmu/Server#1575 Perl usage: ```pl # create as an array, pass as reference my @bag_items = ( { item_id => 1001, charges => 1 }, { item_id => 1002, charges => 1 }, { item_id => 10037, charges => 10 }, ); $client->SummonBaggedItems(17403, \@bag_items); # create directly as an array reference my $bag_items = [ { item_id => 1001, charges => 1 }, { item_id => 1002, charges => 1 }, { item_id => 10037, charges => 10 }, ]; $client->SummonBaggedItems(17403, $bag_items); ``` Lua Usage: ```lua local bag_items = { { item_id = 1001, charges = 1 }, { item_id = 1002, charges = 1 }, { item_id = 10037, charges = 10 } } e.other:SummonBaggedItems(17403, bag_items);
This commit is contained in:
+27
-1
@@ -2229,6 +2229,31 @@ void Lua_Client::UntrainDiscBySpellID(uint16 spell_id, bool update_client) {
|
||||
self->UntrainDiscBySpellID(spell_id, update_client);
|
||||
}
|
||||
|
||||
void Lua_Client::SummonBaggedItems(uint32 bag_item_id, luabind::adl::object bag_items_table) {
|
||||
Lua_Safe_Call_Void();
|
||||
if (luabind::type(bag_items_table) != LUA_TTABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
std::vector<ServerLootItem_Struct> bagged_items;
|
||||
|
||||
luabind::raw_iterator end; // raw_iterator uses lua_rawget
|
||||
for (luabind::raw_iterator it(bag_items_table); it != end; ++it)
|
||||
{
|
||||
// verify array element is a table for item details
|
||||
if (luabind::type(*it) == LUA_TTABLE)
|
||||
{
|
||||
// no need to try/catch, quest lua parser already catches exceptions
|
||||
ServerLootItem_Struct item{};
|
||||
item.item_id = luabind::object_cast<uint32>((*it)["item_id"]);
|
||||
item.charges = luabind::object_cast<int16>((*it)["charges"]);
|
||||
bagged_items.emplace_back(item);
|
||||
}
|
||||
}
|
||||
|
||||
self->SummonBaggedItems(bag_item_id, bagged_items);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_client() {
|
||||
return luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
.def(luabind::constructor<>())
|
||||
@@ -2604,7 +2629,8 @@ luabind::scope lua_register_client() {
|
||||
.def("RemoveItem", (void(Lua_Client::*)(uint32,uint32))&Lua_Client::RemoveItem)
|
||||
.def("SetGMStatus", (void(Lua_Client::*)(int32))&Lua_Client::SetGMStatus)
|
||||
.def("UntrainDiscBySpellID", (void(Lua_Client::*)(uint16))&Lua_Client::UntrainDiscBySpellID)
|
||||
.def("UntrainDiscBySpellID", (void(Lua_Client::*)(uint16,bool))&Lua_Client::UntrainDiscBySpellID);
|
||||
.def("UntrainDiscBySpellID", (void(Lua_Client::*)(uint16,bool))&Lua_Client::UntrainDiscBySpellID)
|
||||
.def("SummonBaggedItems", (void(Lua_Client::*)(uint32,luabind::adl::object))&Lua_Client::SummonBaggedItems);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_inventory_where() {
|
||||
|
||||
Reference in New Issue
Block a user