Thread Tools Display Modes
11/01/15, 10:29 AM   #1
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
Get glyph-prefix from API ?

Is there a API-way to get the prefix of a glyph-link? "grand glyph of health"
Thanks in advance.
  Reply With Quote
11/01/15, 10:44 AM   #2
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
there is no function, but you can get levels with GetItemLinkGlyphMinMaxLevels()
  Reply With Quote
11/01/15, 10:45 AM   #3
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
We added a similar request to the wish-list, already. You may vote for us and add your function request there:
http://www.esoui.com/forums/showthread.php?t=5210
  Reply With Quote
11/02/15, 04:24 AM   #4
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
Thanks, i have voted
  Reply With Quote
11/02/15, 06:16 AM   #5
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,579
Wouldn't something like this work in any language?
Lua Code:
  1. local allowedItemType = {
  2.     [ITEMTYPE_GLYPH_WEAPON] = true,
  3.     [ITEMTYPE_GLYPH_ARMOR] = true,
  4.     [ITEMTYPE_GLYPH_JEWELRY] = true,
  5. }
  6. local function GetItemLinkGlyphPrefix(link)
  7.     if(not allowedItemType[GetItemLinkItemType(link)]) then return end
  8.     -- get the base name of the glyph
  9.     local data = {zo_strsplit(":", link)}
  10.     data[4], data[5] = 0, 0 -- at quality and level 0 there is no prefix
  11.     local baseName = zo_strformat("<<t:1>>", GetItemLinkName(table.concat(data, ":")))
  12.     -- remove the base name from the link
  13.     local name = zo_strformat("<<t:1>>", GetItemLinkName(link))
  14.     return name:gsub(" " .. baseName, "")
  15. end
  16.  
  17. local prefix = GetItemLinkGlyphPrefix(link)
  Reply With Quote
11/02/15, 06:20 AM   #6
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
It should work, just take in consderation that in some language, it's not a prefix, but a suffix.

ex: Glyphe de santé Vraiment Superbe

Last edited by Ayantir : 11/02/15 at 06:29 AM.
  Reply With Quote
11/02/15, 06:26 AM   #7
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,579
ok. that means the gsub needs to be a bit more flexible with removing the whitespace between the name and the prefix/suffix and maybe it also should be called differently (e.g. GetItemLinkGlyphQualityLabel).
  Reply With Quote
11/02/15, 06:42 AM   #8
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by sirinsidiator View Post
Wouldn't something like this work in any language?
No, in French it's in the middle: Glyphe Fort Vital
You could get away with splitting it into words and removing those found in the 0-level name. Seems a bit too complicated (and error-prone) for something that can be done with one table per language.
  Reply With Quote
11/02/15, 07:04 AM   #9
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,579
Originally Posted by merlight View Post
No, in French it's in the middle: Glyphe Fort Vital
You could get away with splitting it into words and removing those found in the 0-level name. Seems a bit too complicated (and error-prone) for something that can be done with one table per language.
True, but where is the fun in that :P

Lua Code:
  1. local allowedItemType = {
  2.     [ITEMTYPE_GLYPH_WEAPON] = true,
  3.     [ITEMTYPE_GLYPH_ARMOR] = true,
  4.     [ITEMTYPE_GLYPH_JEWELRY] = true,
  5. }
  6. local function GetItemLinkGlyphStrengthLabel(link)
  7.     if(not allowedItemType[GetItemLinkItemType(link)]) then return end
  8.     -- get the base name of the glyph
  9.     local data = {zo_strsplit(":", link)}
  10.     data[4], data[5] = 0, 0 -- at quality and level 0 there is no prefix
  11.     local baseName = zo_strformat("<<t:1>>", GetItemLinkName(table.concat(data, ":")))
  12.     -- generate a lookup table of all words in the name
  13.     local baseTokens = {}
  14.     baseName:gsub("(%a+)%s*", function(token) baseTokens[token] = true end)
  15.     -- remove the base name from the link
  16.     local name = zo_strformat("<<t:1>>", GetItemLinkName(link))
  17.     return name:gsub("(%a+)%s*", function(token)
  18.         if(baseTokens[token]) then return "" end
  19.     end):gsub("^%s*(.-)%s*$", "%1")
  20. end
  21.  
  22. local prefix = GetItemLinkGlyphStrengthLabel("|H1:item:5364:0:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h")
  23. df("'%s'", prefix)
  Reply With Quote

ESOUI » AddOns » AddOn Help/Support » Get glyph-prefix from API ?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off