I was wondering what the best way is to iterate over a small table of items where each item id is known. I need to check if the user has it either equipped or in their bags and then provide a clickable item in a DewDrop-2.0 menu.
I've been playing around with GetItemInfo(), but it doesn't seem to be returning anything. Any ideas?
If GetItemInfo() doesn't return anything, it means the user has not seen the item on any character on that particular computer since the last patch/launcher update.
Woot! I figured it out! I had to register a BAG_UPDATE (which triggers an update to the item list) with my log-in event. Then I actually checked to make sure the "item" wasn't nil. Now all I have to do is figure out how to iterate through the bags/items and see what the user actually has. >.<
Would it be better to iterate through each bag slot and compare it to each item in the table or iterate through the table and compare it to each slot? It's in my head that it doesn't matter, but I want to make sure. >.<
The BAG_UPDATE event gives you the bagID (arg1) twice for every move and once if you pick up an item, it's thrown at you (Heavy Leather Ball, anyone?), or you equip/unequip it. So if you move an item from bag 0 to bag 3, the event will fire for bag 0 and bag 3 in that order and it will fire for twice for the same bag if moving from slot to slot in the same bag. You could, conceivably, scan only the arg1 bag for changes per event.
Also note, that this event also fires for bank bags and the bank frame.
Right, but for some reason it wasn't firing at login so I had to force it to fire (as I mentioned above). Of course, as much of a rookie as I am, I probably had something screwy. If it's supposed to fire on login, I'll look it over.
As far as scanning goes, I'd still have to scan all of the bag slots initially but I see what you're saying. Though wouldn't I have to scan both bags (on a move) to ensure it's not being put in the bank?
And yeah, I realize it fires for the bank bags/frame. But that's really the only event I can use for the purpose, isn't it? Blah! I just realized I have to figure out how to handle equipped items as well. /cry
Edit: GRR! And why the heck do I have to declare a function before another function that uses it? What is this? 1980? :P
You may be able to do something like GetItemInfo(GetItemInfo(id)). GetItemInfo(id) will return the name of the item (or was it link? anyway), and calling GetItemInfo with a name (or link) parameter only works if you have the item equipped or in your bags. (possibly bank, too, I guess)
You may be able to do something like GetItemInfo(GetItemInfo(id)). GetItemInfo(id) will return the name of the item (or was it link? anyway), and calling GetItemInfo with a name (or link) parameter only works if you have the item equipped or in your bags. (possibly bank, too, I guess)
Redundant. You might as well have just used GetItemCount(itemid/itemstring/link/name[, includebank])
Right, but for some reason it wasn't firing at login so I had to force it to fire (as I mentioned above). Of course, as much of a rookie as I am, I probably had something screwy. If it's supposed to fire on login, I'll look it over.
According to WoWWiki the default backpack may not fire at logon, but the rest of them should (1, 2, 3, and 4).
I was wondering what the best way is to iterate over a small table of items where each item id is known. I need to check if the user has it either equipped or in their bags and then provide a clickable item in a DewDrop-2.0 menu.
I've been playing around with GetItemInfo(), but it doesn't seem to be returning anything. Any ideas?
Would it be better to iterate through each bag slot and compare it to each item in the table or iterate through the table and compare it to each slot? It's in my head that it doesn't matter, but I want to make sure. >.<
Also note, that this event also fires for bank bags and the bank frame.
As far as scanning goes, I'd still have to scan all of the bag slots initially but I see what you're saying. Though wouldn't I have to scan both bags (on a move) to ensure it's not being put in the bank?
And yeah, I realize it fires for the bank bags/frame. But that's really the only event I can use for the purpose, isn't it? Blah! I just realized I have to figure out how to handle equipped items as well. /cry
Edit: GRR! And why the heck do I have to declare a function before another function that uses it? What is this? 1980? :P
Redundant. You might as well have just used GetItemCount(itemid/itemstring/link/name[, includebank])
Hm... That function might save me a lot of work. >.< I should pay more attention, lol.
Good point.
According to WoWWiki the default backpack may not fire at logon, but the rest of them should (1, 2, 3, and 4).