mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-25 16:30:15 +00:00
feat: add BuyMerchantItem and SellContainerItem for vendor interaction
BuyMerchantItem(index, count) purchases an item from the current vendor by merchant slot index. Resolves itemId and slot from the vendor's ListInventoryData. SellContainerItem(bag, slot) sells an item from the player's inventory to the vendor. Supports backpack (bag=0) and bags 1-4. Enables auto-sell addons (Scrap, AutoVendor) and vendor UI addons to buy/sell items programmatically.
This commit is contained in:
parent
0a2667aa05
commit
79bc3a7fb6
1 changed files with 21 additions and 0 deletions
|
|
@ -5062,6 +5062,27 @@ void LuaEngine::registerCoreAPI() {
|
|||
lua_pushboolean(L, 1); // isCastable
|
||||
return 4;
|
||||
}},
|
||||
// --- Vendor Buy/Sell ---
|
||||
{"BuyMerchantItem", [](lua_State* L) -> int {
|
||||
auto* gh = getGameHandler(L);
|
||||
int index = static_cast<int>(luaL_checknumber(L, 1));
|
||||
int count = static_cast<int>(luaL_optnumber(L, 2, 1));
|
||||
if (!gh || index < 1) return 0;
|
||||
const auto& items = gh->getVendorItems().items;
|
||||
if (index > static_cast<int>(items.size())) return 0;
|
||||
const auto& vi = items[index - 1];
|
||||
gh->buyItem(gh->getVendorGuid(), vi.itemId, vi.slot, count);
|
||||
return 0;
|
||||
}},
|
||||
{"SellContainerItem", [](lua_State* L) -> int {
|
||||
auto* gh = getGameHandler(L);
|
||||
int bag = static_cast<int>(luaL_checknumber(L, 1));
|
||||
int slot = static_cast<int>(luaL_checknumber(L, 2));
|
||||
if (!gh) return 0;
|
||||
if (bag == 0) gh->sellItemBySlot(slot - 1);
|
||||
else if (bag >= 1 && bag <= 4) gh->sellItemInBag(bag - 1, slot - 1);
|
||||
return 0;
|
||||
}},
|
||||
// --- Repair ---
|
||||
{"RepairAllItems", [](lua_State* L) -> int {
|
||||
auto* gh = getGameHandler(L);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue