View Single Post
03-21-13, 04:52 AM   #32
fRodzet
A Flamescale Wyrmkin
Join Date: Mar 2013
Posts: 114
Originally Posted by Phanx View Post
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:
  1. "|Hitem"
  2. "12345"
  3. "0"
  4. "1"
  5. "2"
  6. "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:
  1. local supportedType = {
  2.       spell = true,
  3.       item = true,
  4.       quest = true,
  5.       achievement = true,
  6.       talent = true,
  7.       glyph = true,
  8.       unit = true,
  9.       enchant = true
  10.     }
  11.  
  12. local function ChatlinkTooltips_ShowTip(self, linkData)
  13.     local linkType = strmatch(linkData, "|H(.-):")
  14.     if supportedType[linkType] then
  15.         GameTooltip:SetOwner(self, "ANCHOR_CURSOR")
  16.         GameTooltip:SetHyperlink(linkData)
  17.         GameTooltip:Show()
  18.     end
  19. end
  20.  
  21. local function ChatlinkTooltips_HideTip()
  22.     GameTooltip:Hide()
  23. end
  24.  
  25. local function ChatlinkTooltips_HookHandler(frame, event, func)
  26.     frame:HookScript(event, func) -- Sets & Hooks the script
  27. end
  28.  
  29.     for i = 1, NUM_CHAT_WINDOWS do
  30.     local frame = _G["ChatFrame" .. i] -- Copy a reference
  31.         ChatlinkTooltips_HookHandler(frame, "OnHyperLinkEnter", ChatlinkTooltips_ShowTip)
  32.         ChatlinkTooltips_HookHandler(frame, "OnHyperLinkLeave", ChatlinkTooltips_HideTip)
  33. end
  Reply With Quote