GetItemFamily, bitfield
I dont have WoW access atm but got little request to my addon and require help now :)
I want to find out if given item is used for enchanting or not. I found GetItemFamily but dunno how to work with bitfield, so probably something like Lua Code:
|
if bit.band(GetItemFamily(item), 0x0040) > 0 then
|
i was 2nd hand testing :)
/run if bit.band(GetItemFamily("Sha Crystal"), 0x0040) > 0 then print("1") else print("0") end it throws erorr: Message: [string "if bit.band(GetItemFamily("Sha Crystal"), 0..."]:1: bad argument #1 to 'band' (number expected, got nil) |
I just copied and pasted your run statement and got 1.
|
Quote:
|
I just re-started the game and logged on to a non enchanter and recieved the error so it seems the function is inteded for items already in your bags.
Quote:
|
Quote:
|
thx all
wonder how it would act when disenchanting something into Sha Crystal (or anything else) without any of tht reagent in bags its too much to ask for running that script with disenchant loot window open and no crystals in bags? :D |
Sadly it also works if you have the item in your bank or bags.
Why not change it to: /run local var = GetItemFamily("Sha Crystal"); if var and bit.band(var, 0x0040) > 0 then print("1") else print("0") end Quote:
|
but that wont determine if given item is a enchanting material or not
wanted it works for all, but well, i 'hardcode' it with sha crystal ID somehow without use of GetItemFamily |
/run if bit.band(GetItemFamily(74248), 0x0040) > 0 then print("1") else print("0") end
Where 74248 is the item id of a Sha Crystal works on a non-enchanter with no crystals. Quote:
|
ive just changed
local _, item, quantity, quality = GetLootSlotInfo(i) if quality >= 4 then into local _, item, quantity, quality = GetLootSlotInfo(i) if item ~= GetItemInfo(74248) and quality >= 4 then my lil addon will need rewrite in WoD anyway so i think then |
If GetItemInfo works then so does GetitemFamily, they both rely on the item being cached.
If I understand what you're trying to do here, and you only want items that are at least epic quality and aren't considered enchanting materials, then you can try something like this.. Lua Code:
|
You should always use itemIDs anyway. Using item names has a number of flaws, such as restricting your addon to only work in English game clients, failing for items you haven't seem during your play session, etc. IDs are better in every way.
If you really need to compare strings against item names, rather than calling GetItemInfo every time, call it once and store the result in a variable outside of whatever function you're comparing in, then use the variable inside that function: local SHA_CRYSTAL = GetItemInfo(74248)Or use GetLootSlotLink instead of GetLootSlotInfo and extract the itemID from the link: local link = GetLootSlotLink(i)However, without knowing your actual goals (eg. why you want to know whether an item is used for enchanting, and what you want to do with that knowledge), it's hard to really offer any specific useful suggestions. |
Quote:
Phanx -> but i get item name from game, so its should be localized? Example was just for testing. Figuring out if its enchanting material or not seemed more elegant then putting all those ID's and then update it with every WoW tier. http://www.wowinterface.com/download...Announcer.html its that addon (announces in raid chat numbered list of dropped items from boss, but can fire also on disenchanting loot window) i am talking about and got recently request to exclude disenchant info (can produce unnecessary spam and atm it is most likely Sha Crystals) So i guess i can use GetItemFamily for my needs - item being checked will be in loot window and should be cached then? Or maybe GetLootSourceInfo will produce something that will allows me to exclude disenchant in first place? |
Quote:
Quote:
Code:
-- LOOT_OPENED |
looks great but what if loot is not from body but from chest?
i use GetItemFamily just like in your first anwser :) thanks all |
All times are GMT -6. The time now is 03:27 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI