View Single Post
06/27/14, 06:19 PM   #38
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Garkin View Post
If I use d(zo_strformat("text <<t:1>>", itemLink)), it will print "textitemlink" - all spaces in front of the itemlink are removed. Is there any way how to get it working correctly?
If itemLink does not contain text all spaces between text and link will be removed. However if link contain text, it works correctly.

My solution (my workaround ):
Lua Code:
  1. local function GetBetterItemLink(bagId, slotId, linkStyle)
  2.    local link = GetItemLink(bagId, slotId, linkStyle)
  3.    if link == "" then return end
  4.  
  5.    local name = GetItemName(bagId, slotId)
  6.    local data = link:match("|H.-:(.-)|h")
  7.  
  8.    if linkStyle == LINK_STYLE_BRACKETS then
  9.       return ("|H%s:%s|h[%s]|h"):format(LINK_STYLE_BRACKETS, data, name)
  10.    else
  11.       return ("|H%s:%s|h%s|h"):format(LINK_STYLE_DEFAULT, data, name)
  12.    end
  13. end
  14.  
  15. local itemLink = GetBetterItemLink(bagId, slotId)
  16. d(zo_strformat("text <<t:1>>", itemLink))
  Reply With Quote