Originally Posted by Phanx
If your string looks like this:
" |Hitem:12345:0:1:2:3|h[Random Item of the X]|h"
...then string.split on colons returns: - "|Hitem"
- "12345"
- "0"
- "1"
- "2"
- "3|h[Random Item of the X]|h"
...whereas string.match to capture what's between the first "|H" and the first following ":" returns only "item":
|Hitem:12345:0:1:2:3|h[Random Item of the X]|h
|
okay i get the idea now.. However if i type: local linkType = strmatch(linkData, "|H(.-):") it doesn't show any tooltips when mouse hovering also tried string.match(x, x).. maybe some of my other code needs to be changed also then - but looked it all trough, dno what should be changed then.
Here is the code, but it won't work properly:
Lua Code:
local supportedType = {
spell = true,
item = true,
quest = true,
achievement = true,
talent = true,
glyph = true,
unit = true,
enchant = true
}
local function ChatlinkTooltips_ShowTip(self, linkData)
local linkType = strmatch(linkData, "|H(.-):")
if supportedType[linkType] then
GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
GameTooltip:SetHyperlink(linkData)
GameTooltip:Show()
end
end
local function ChatlinkTooltips_HideTip()
GameTooltip:Hide()
end
local function ChatlinkTooltips_HookHandler(frame, event, func)
frame:HookScript(event, func) -- Sets & Hooks the script
end
for i = 1, NUM_CHAT_WINDOWS do
local frame = _G["ChatFrame" .. i] -- Copy a reference
ChatlinkTooltips_HookHandler(frame, "OnHyperLinkEnter", ChatlinkTooltips_ShowTip)
ChatlinkTooltips_HookHandler(frame, "OnHyperLinkLeave", ChatlinkTooltips_HideTip)
end