Saturday, April 21, 2012

Socket colors

How can I find out what SOCKETS are available, based on a certain item (item id and so on obtained via GetItem())?

For example, I am not interested in what gems are socketed, I want to know what sockets are available, i.e. 2 red sockets and 1 blue socket.

Sort of like this:

local r,y,b,m = GetSocketColors( ItemLink )

Variables r,y,b,m would contain a number, in the example above 2,0,1,0 for 2 red socket slots, 0 yellow, 1 blue and 0 meta slot.

Is this possible? I mean, it is possible to read the string "Red socket" if the item has no gems socketed, but that is not sufficient for what I had in mind.

Hope someone can help with this. Thanks in advance!|||I don't know if what you exactly want is here but check out these pages to give you a place to start looking.

itemlink @ http://www.wowwiki.com/ItemString

"itemLink" = GetInventoryItemLink("unit", slotId) @ http://www.wowwiki.com/API_GetInventoryItemLink|||The only way of checking what sockets are available that I know of is to scan the tooltip of an item.

Read through http://wowwiki.com/UIOBJECT_GameTooltip to get a basic idea of how to scan tooltips.|||I don't know if you misunderstood me, of if I was unclear about the issue.

I have no problems getting the ItemLink or scan the tooltips (as you suggested). What I don't know how to do, either while scanning the tooltip or in some other way based on an item id or an ItemLink, is to find out what SOCKETS are available. Please note: I have no interest at all what gems are socketed, I want to know the color of the actual socket - for example, you can put a red gem in a blue socket - I want to check the color of the socket (blue), not the gem (red).

When a gem is socketed, scanning the tooltip doesn't seem to return any information about the socket color, which is why I am here, asking you for help|||I understood what you meant, and there's no blizzard API to do it (that I know of, I could easily be wrong.)

You can scan the tooltip to get available sockets, but remember that tooltips don't just contain text, you have to look at the images too.

Basically, as well as GameTooltipText, theres GameTooltipTexture1 (2, 3, 4, etc)

Try this:

Set the tooltip to the item ID only of whatever item you want to scan (just the ID means it clears any sockets the item has, so you will only get the sockets as if it were never socketed). For example, GameTooltip:SetHyperlink("item:32006")

Scan GameTooltipTexture1, GameTooltipTexture2, etc up to 10 to see if their GetTexture() returns these strings:

"Interface\\ItemSocketingFrame\\UI-EmptySocket-Meta"

"Interface\\ItemSocketingFrame\\UI-EmptySocket-Blue"

"Interface\\ItemSocketingFrame\\UI-EmptySocket-Red"

"Interface\\ItemSocketingFrame\\UI-EmptySocket-Yellow"|||Quote:








What I don't know how to do, either while scanning the tooltip or in some other way based on an item id or an ItemLink, is to find out what SOCKETS are available.




You can't get the socket colors of an item purely by sniffing its itemlink. Plain and simple. What you can (reliably) get from an itemlink is the itemID, enchantID, suffix (if any), instance, and the the ID's of any gems socketed.


Quote:




When a gem is socketed, scanning the tooltip doesn't seem to return any information about the socket color, which is why I am here, asking you for help




Correct. It only returns the id of the gem or gems as I noted above. To the best of my knowledge as well there is no API to get the gem colors, so you either have to scan the itemlink and search for plain strings like "<Color> Socket" or "Meta Socket" (you still have to set the hyperlink to that of the original, unsocketed item) or use dinnerbone's approach and possibly check for the texture.|||Quote:








search for plain strings like "<Color> Socket" or "Meta Socket" (you still have to set the hyperlink to that of the original, unsocketed item)




I would not recomend this method unless the addon is going to be a private one, as "Meta Socket" would change in each language, but textures do not.|||Correct, if you mix with strings, there is always localization to consider.|||Tristanian, Dinnerbone... Many thanks!

Haven't had the time to test this yet (currently at work), but GetTexture() was a new one for me (yes, I am a noob when it comes to addons). And although the addon is a private one, so far, it is always better to try to stay away from localized strings, I know

I will post back in this thread if I come up with anything whether it is a solution or a new question/problem|||Here's what I did, no time to go further, have raiding to do

XML:

<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/">

<GameTooltip name="MyScanningTooltip" inherits="GameTooltipTemplate">

<Scripts>

<Onload>

this:SetOwner(UIParent, "ANCHOR_NONE");

</Onload>

</Scripts>

</GameTooltip>

</Ui>



LUA:

MyScanningTooltip:ClearLines();

MyScanningTooltip:SetHyperlink("item:"..id)

local tmp = getglobal("MyScanningTooltipTexture1"):GetTexture();

Result: tmp contains for example "Interface\ItemSocketingFrame\UI-EmptySocket-Blue"

For now, this result is exactly in the direction I wanted to go

Thanks for pointing me in the right direction!

No comments:

Post a Comment