ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Help/Support (https://www.esoui.com/forums/forumdisplay.php?f=164)
-   -   Get glyph-prefix from API ? (https://www.esoui.com/forums/showthread.php?t=5245)

@AlphaLemming 11/01/15 10:29 AM

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.

Ayantir 11/01/15 10:44 AM

there is no function, but you can get levels with GetItemLinkGlyphMinMaxLevels()

votan 11/01/15 10:45 AM

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

@AlphaLemming 11/02/15 04:24 AM

Thanks, i have voted :)

sirinsidiator 11/02/15 06:16 AM

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)

Ayantir 11/02/15 06:20 AM

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

sirinsidiator 11/02/15 06:26 AM

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).

merlight 11/02/15 06:42 AM

Quote:

Originally Posted by sirinsidiator (Post 24045)
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.

sirinsidiator 11/02/15 07:04 AM

Quote:

Originally Posted by merlight (Post 24048)
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)

Wandamey 11/02/15 08:25 AM

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)

@AlphaLemming 11/02/15 09:04 AM

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

merlight 11/02/15 09:45 AM

Quote:

Originally Posted by @AlphaLemming (Post 24052)
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

@AlphaLemming 11/05/15 02:32 AM

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


All times are GMT -6. The time now is 10:03 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI