Quantcast
WoWInterface - View Single Post - How to track if a Reagent was used from Reagent Bank while crafting?
View Single Post
02-19-21, 09:13 AM   #3
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 982
Originally Posted by Xruptor View Post
determine if an item was used from the Reagent Bank during crafting

PLAYERREAGENTBANKSLOTS_CHANGED fires when an item is crafted from the reagent bank, or an item was deposited/withdrawn/moved in the reagent bank

Lua Code:
  1. -- assume the player just crafted something
  2. local function OnEvent(self, event, reagentSlot)
  3.     local inventoryID = ReagentBankButtonIDToInvSlotID(reagentSlot)
  4.     local itemID = GetInventoryItemID("player", inventoryID)
  5.     local itemLink = select(2, GetItemInfo(itemID))
  6.  
  7.     print(format("item %d %s was used from your reagent bank", itemID, itemLink))
  8.     print("reagentSlot:", reagentSlot)
  9.     print("inventoryID:", inventoryID)
  10. end
  11.  
  12. local f = CreateFrame("Frame")
  13. f:RegisterEvent("PLAYERREAGENTBANKSLOTS_CHANGED")
  14. f:SetScript("OnEvent", OnEvent)
Code:
item 2840 [Copper Bar] was used from your reagent bank
reagentSlot: 1
inventoryID: 99
You create: [Handful of Copper Bolts].

Originally Posted by Xruptor View Post
use GetTradeSkillReagentInfo and grab the playerReagentCount to determine if the reagent count is greater than what the player has in their inventory.
Probably something like that, yes

Last edited by Ketho : 02-19-21 at 09:39 AM.
  Reply With Quote