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,578
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,578
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,578
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
11/02/15, 08:25 AM   #10
Wandamey
Guest
Posts: n/a
For me anyway, it's not the point, the point is to be able to generate the name of the glyph from the potency rune or (from any level info...)

so far, you have to either make a complete table for all languages (as in Merlin) or generate the data through time knowing that for this you need to have 1 rune of each type in you bag and have learned them already. Which won't help people who need this info the most : newbies that are trying to do their first writs.

With it I could avoid some serious looping when my addon selects the writ components at the station too or inform which rune is missing. So far I can't. (lets say i'm too lazy to maintain a table)

Last edited by Wandamey : 11/02/15 at 08:29 AM.
  Reply With Quote
11/02/15, 09:04 AM   #11
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
I will try it this way (not yet tested):
Lua Code:
  1. function CS.RuneGetLink(id,quality,rank)
  2.     local color = {19,19,19,19,19,19,19,19,19,115,117,119,121,271,307,365,[0] = 0}
  3.     local adder = {1,1,1,1,1,1,1,1,1,10,10,10,10,1,1,1,[0] = 0}
  4.     local level = {5,10,15,20,25,30,35,40,45,50,50,50,50,50,50,50,[0] = 0}
  5.     return ('|H1:item:%u:%u:%u:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h'):format(id,(color[rank] + quality * adder[rank]),level[rank])
  6. end
  7.  
  8. local function Split(level)
  9.     local basename = GetItemLinkName(CS.RuneGetLink(26580,0,0))
  10.     local basedata = { zo_strsplit(' ', basename) }
  11.     local name = zo_strformat('<<t:1>>', GetItemLinkName(CS.RuneGetLink(26580,3,level)))
  12.     local namedata = { zo_strsplit(' ', name) }
  13.     for x, name in pairs(namedata) do
  14.         for y, base in pairs(basedata) do
  15.             if name == base then table.remove(namedata,x); table.remove(basedata,y); break end
  16.         end
  17.     end
  18.     return zo_strformat('<<C:1>>', table.concat(namedata,' '))
  19. end

Last edited by @AlphaLemming : 11/02/15 at 09:46 AM.
  Reply With Quote
11/02/15, 09:45 AM   #12
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by @AlphaLemming View Post
I will try it this way (not yet tested):
Lua Code:
  1. for x, name in pairs(namedata) do
  2.         for y, base in pairs(basedata) do
  3.             if name == base then table.remove(namedata,x); table.remove(basedata,y); break end
  4.         end
  5.     end
  6. end
This won't work because table.remove shifts indices, and you will skip the next value (edit: removed incorrect info; you can delete table values during traversal). Anyway you don't need 2 nested loops. Assuming the 0-level name has fewer words, you can:
Lua Code:
  1. local i = #basedata
  2. for j = #namedata, 1, -1 do
  3.     if namedata[j] == basedata[i] then
  4.         table.remove(namedata, j)
  5.         i = i - 1
  6.     end
  7. end

Last edited by merlight : 11/05/15 at 05:49 AM.
  Reply With Quote
11/05/15, 02:32 AM   #13
@AlphaLemming
 
@AlphaLemming's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 122
This works for me, but not tested in french:

Lua Code:
  1. -- Returns a glyph-link in wanted quality and level
  2. local function RuneGetLink(id,quality,rank)
  3.     local color = {19,19,19,19,19,19,19,19,19,115,117,119,121,271,307,365,[0] = 0}
  4.     local adder = {1,1,1,1,1,1,1,1,1,10,10,10,10,1,1,1,[0] = 0}
  5.     local level = {5,10,15,20,25,30,35,40,45,50,50,50,50,50,50,50,[0] = 0}
  6.     return ('|H1:item:%u:%u:%u:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h'):format(id,(color[rank] + quality * adder[rank]),level[rank])
  7. end
  8. -- Returns the glyph-prefix for the wanted level
  9. local function Split(level)
  10.     local basename = zo_strformat('<<t:1>>', GetItemLinkName(RuneGetLink(26580,0,0)))
  11.     local basedata = { zo_strsplit(' ', basename) }
  12.     local name = zo_strformat('<<t:1>>', GetItemLinkName(RuneGetLink(26580,3,level)))
  13.     local namedata = { zo_strsplit(' ', name) }
  14.     for j = #namedata, 1, -1 do
  15.         for i = #basedata, 1, -1 do
  16.         if namedata[j] == basedata[i] then
  17.             table.remove(namedata, j)
  18.             table.remove(basedata, i)
  19.         end end
  20.     end
  21.     return zo_strformat('<<C:1>>', table.concat(namedata,' '))
  22. end
  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