It's really hard to do this in a clean way, because to my knowledge there is no event or script handler for when you mouseover a gathering node or when the GameTooltip is set to a world object. I could be wrong about this, so there could be a simpler solution.
In any case, here's what I came up with:
Code:
local MINING_GLOVES = "Biornskin Belt"
local HERBALISM_GLOVES = "Dreadhide Girdle"
local LOCALIZED_HERBALISM = "Herbalism"
local LOCALIZED_MINING = "Mining"
local GameTooltip = GameTooltip
local GameTooltipTextLeft2 = GameTooltipTextLeft2
local EquipItemByName = EquipItemByName
local function ScanTooltip()
if GameTooltip:NumLines() ~= 2 then return end
local text = GameTooltipTextLeft2:GetText()
if text:find(LOCALIZED_MINING) then
EquipItemByName(MINING_GLOVES)
elseif text:find(LOCALIZED_HERBALISM) then
EquipItemByName(HERBALISM_GLOVES)
end
end
GameTooltip:HookScript("OnTooltipSetDefaultAnchor", function(self)
self:SetWidth(1)
end)
GameTooltip:HookScript("OnSizeChanged", function()
ScanTooltip()
end)
It scans tooltip text, so it requires localized version of "Mining" and "Herbalism". This is the text you see in the second line in your tooltip when you mouseover a gathering node, so keep that in mind, just in case it's different from the profession names in some localizations.
OnTooltipSetDefaultAnchor runs every time you mouse over a world object, so it's a reliable script handler to check. However, it runs before the contents of the tooltip are updated. Momentarily I tried running the ScanTooltip function after a delay using C_Timer.After, but it felt like such a dirty solution, that I decided to instead enforce OnSizeChanged by manually changing the tooltip size, so that when the tooltip updates, it must change size.
OnSizeChanged runs after the contents of the tooltip have been updated, but only if the size of the tooltip actually changed. As it turns out, even during my short testing I managed to find some mobs in Suramar, whose tooltip was exactly the same size as the tooltip for Leyline Deposits, so this handler didn't run, if I moved my mouse from one of the mobs to the mining node. This is why it cannot reliably be used alone, but combined with OnTooltipSetDefaultAnchor it should run every time you mouse over an object in the game world.
I'm not 100% satisfied with how it turned out, since it's not a totally clean solution, but it should work, which is what matters.
It won't swap your gloves, if you were in combat as you put your mouse over the gathering node, and then left combat without ever moving your mouse, but that's such a rare issue that I don't care to fix it. If that happens, just quickly move your mouse away from the gathering node and then back.
To use it code, either run it with an AddOn that can run custom Lua code snippets, I use Hack for that, or turn it into an AddOn yourself. Here's a guide on how to make your own AddOn from a code snippet:
http://www.mmo-champion.com/threads/...lve-easy-steps
BTW, the current game version is of course 70000, but it hasn't been updated in the guide.