WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   LUA function for getting item enchants (https://www.wowinterface.com/forums/showthread.php?t=46483)

Malsomnus 05-18-13 04:28 AM

LUA function for getting item enchants
 
Is there a way in the API to check the enchants on an item that I currently have equipped? I've been unable to find one so far...

ravagernl 05-18-13 04:50 AM

To check for an enchant, you need to parse the itemstring.

You can get an itemlink for a slot in your inventory with GetInventoryItemLink:
lua Code:
  1. local slotId = GetInventorySlotInfo("ChestSlot")
  2. local link = GetInventoryItemLink("player", slotId)
  3. local itemId, enchantId, gem1, gem2, gem3, gem4 = link:match("item:(%d+):(%d+):(%d+):(%d+):(%d+):(%d+)")
Tekkub's Bimbo is an excellent example of how you can detect enchants/gems.

Malsomnus 05-18-13 05:07 AM

Ooh, I didn't know you could get that sort of info out of an item link... thanks :)

[edit]
I can't find anything about what these enchant/ gem numbers mean though, including in Bimbo... they aren't spell IDs nor item IDs.

pelf 05-18-13 06:53 AM

Well, there's this page: http://www.wowpedia.org/EnchantId

It doesn't look very updated. Not sure what the best practice is for dealing with enchantIds.

Taraezor 08-29-13 06:51 AM

Forgive the Necro but this thread shows up in searches and I don't want people to get the wring idea: The above discussion does NOT apply to the buffs Shaman put on their weapon.

Aside from parsing Tooltips and/or monitoring logs to see when Windfury etc were applied, there is no way of knowing the enchant put on a Shaman's weapon.

In the case of Shaman's, you will get a 0 (zero) in the colon separated string list.

Malsomnus 08-29-13 08:09 AM

Well, if this thread has already been resurrected...
I eventually solved the problem by creating an item link for a stat-less item with the given enchant ID and parsing its tooltip, and would like to thank the author of this add-on for the idea (and most of the implementation).

As for shamans, I used GetWeaponEnchantInfo to see if a weapon enchant exists, but this indeed does not tell me what the enchant is.

suicidalkatt 08-29-13 08:11 AM

Quote:

Originally Posted by Taraezor (Post 283638)
Forgive the Necro but this thread shows up in searches and I don't want people to get the wring idea: The above discussion does NOT apply to the buffs Shaman put on their weapon.

Aside from parsing Tooltips and/or monitoring logs to see when Windfury etc were applied, there is no way of knowing the enchant put on a Shaman's weapon.

In the case of Shaman's, you will get a 0 (zero) in the colon separated string list.

What about this: http://wowprogramming.com/docs/api/GetWeaponEnchantInfo ?

Phanx 08-29-13 05:48 PM

Quote:

Originally Posted by suicidalkatt (Post 283640)

As both the post directly before yours and the linked page itself point out, that function does not tell you which temporary enchant is on the weapon. The only way to determine which temporary enchant is on the weapon is to scan its tooltip and use localized string matching. If anyone is trying to do this, feel free to copy the code from PhanxBuffs; it detects all temp enchants currently in the game, and maps them to the spell that applies them.

Resike 08-30-13 02:59 AM

I think the best method is if you really want to find all enchants for weapons is that you scan the mainhand/offhand weapons tooltip with the enchant id's localized name.

Phanx 08-30-13 03:10 PM

... that's what I just said? :confused:

humfras 08-30-13 05:49 PM

Quote:

Originally Posted by Phanx (Post 283662)
... that's what I just said? :confused:

No. But that's what you just wrote! ;)

Resike 02-17-16 09:00 AM

Since 6.0 you can get the temporary enchant ids from GetWeaponEnchantInfo():

Lua Code:
  1. local hasMainHandEnchant, mainHandExpiration, mainHandCharges, mainHandEnchantID, hasOffHandEnchant, offHandExpiration, offHandCharges, offHandEnchantId = GetWeaponEnchantInfo()

The issue now, is that you don't know the duration of the enchants.

But you can filter the fishing lure enchants or fall back to 3600 like this:

Lua Code:
  1. local tempEnchantID = {
  2.     [256] = 600, -- (+75)
  3.     [263] = 600, -- (+25)
  4.     [264] = 600, -- (+50)
  5.     [265] = 600, -- (+75)
  6.     [266] = 600, -- (+100)
  7.     [3868] = 3600, -- (+100)
  8.     [4225] = 900, -- (+150)
  9.     [4264] = 600, -- (+15)
  10.     [4919] = 600, -- (+150)
  11.     [5386] = 600, -- (+200)
  12. }
  13.  
  14. local hasMainHandEnchant, mainHandExpiration, mainHandCharges, mainHandEnchantID, hasOffHandEnchant, offHandExpiration, offHandCharges, offHandEnchantId = GetWeaponEnchantInfo()
  15. local duration = tempEnchantID[mainHandEnchantID] or 3600
  16. frame.cooldown:SetCooldown(GetTime() + ((mainHandExpiration / 1000) - duration), duration)


All times are GMT -6. The time now is 08:43 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI