mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-17 03:08:26 +00:00
[Quest API] Add AddItem() to Perl/Lua. (#2054)
- Add $client->AddItem(item_data) to Perl.
- Add client:AddItem(item_table) to Lua.
- This will allow server operators to add items without needless parameters.
Perl Example:
```pl
my %item_data = (
"item_id" => 1200,
"charges" => 1,
"augment_one" => 49656,
"augment_two" => 49656,
"augment_three" => 49656,
"augment_four" => 49656,
"augment_five" => 49656,
"augment_six" => 49656,
"attuned" => 1,
"slot_id" => quest::getinventoryslotid("general1")
);
$client->AddItem(\%item_data);
```
Lua Example:
```lua
local item_data = {
item_id = 1200,
charges = 1,
augment_one = 49656,
augment_two = 49656,
augment_three = 49656,
augment_four = 49656,
augment_five = 49656,
augment_six = 49656,
attuned = true,
slot_id = Slot.General1
};
e.self:AddItem(item_data);
```
This commit is contained in:
@@ -2366,6 +2366,37 @@ void Lua_Client::SetInvulnerableEnvironmentDamage(bool value) {
|
||||
self->SetInvulnerableEnvironmentDamage(value);
|
||||
}
|
||||
|
||||
void Lua_Client::AddItem(luabind::object item_table) {
|
||||
Lua_Safe_Call_Void();
|
||||
if (luabind::type(item_table) != LUA_TTABLE) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 item_id = luabind::object_cast<uint32>(item_table["item_id"]);
|
||||
int16 charges = luabind::object_cast<uint32>(item_table["charges"]);
|
||||
uint32 augment_one = luabind::type(item_table["augment_one"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_one"]) : 0;
|
||||
uint32 augment_two = luabind::type(item_table["augment_two"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_two"]) : 0;
|
||||
uint32 augment_three = luabind::type(item_table["augment_three"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_three"]) : 0;
|
||||
uint32 augment_four = luabind::type(item_table["augment_four"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_four"]) : 0;
|
||||
uint32 augment_five = luabind::type(item_table["augment_five"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_five"]) : 0;
|
||||
uint32 augment_six = luabind::type(item_table["augment_six"]) != LUA_TNIL ? luabind::object_cast<uint32>(item_table["augment_six"]) : 0;
|
||||
bool attuned = luabind::type(item_table["attuned"]) != LUA_TNIL ? luabind::object_cast<bool>(item_table["attuned"]) : false;
|
||||
uint16 slot_id = luabind::type(item_table["slot_id"]) != LUA_TNIL ? luabind::object_cast<uint16>(item_table["slot_id"]) : EQ::invslot::slotCursor;
|
||||
|
||||
self->SummonItem(
|
||||
item_id,
|
||||
charges,
|
||||
augment_one,
|
||||
augment_two,
|
||||
augment_three,
|
||||
augment_four,
|
||||
augment_five,
|
||||
augment_six,
|
||||
attuned,
|
||||
slot_id
|
||||
);
|
||||
}
|
||||
|
||||
luabind::scope lua_register_client() {
|
||||
return luabind::class_<Lua_Client, Lua_Mob>("Client")
|
||||
.def(luabind::constructor<>())
|
||||
@@ -2381,6 +2412,7 @@ luabind::scope lua_register_client() {
|
||||
.def("AddExpeditionLockout", (void(Lua_Client::*)(std::string, std::string, uint32, std::string))&Lua_Client::AddExpeditionLockout)
|
||||
.def("AddExpeditionLockoutDuration", (void(Lua_Client::*)(std::string, std::string, int))&Lua_Client::AddExpeditionLockoutDuration)
|
||||
.def("AddExpeditionLockoutDuration", (void(Lua_Client::*)(std::string, std::string, int, std::string))&Lua_Client::AddExpeditionLockoutDuration)
|
||||
.def("AddItem", (void(Lua_Client::*)(luabind::adl::object))&Lua_Client::AddItem)
|
||||
.def("AddLDoNLoss", (void(Lua_Client::*)(uint32))&Lua_Client::AddLDoNLoss)
|
||||
.def("AddLDoNWin", (void(Lua_Client::*)(uint32))&Lua_Client::AddLDoNWin)
|
||||
.def("AddLevelBasedExp", (void(Lua_Client::*)(int))&Lua_Client::AddLevelBasedExp)
|
||||
|
||||
Reference in New Issue
Block a user