Thread Tools Display Modes
07/03/14, 01:42 AM   #1
Khaibit
 
Khaibit's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 26
Extracting string item names from links post-1.2.3?

I've had this discussion a little with farangkao in a patch thread, but I wanted to open it up to anyone else's ideas. For background - item link format changed recently, see http://www.esoui.com/forums/showthread.php?t=1811 first post for details. TL;DR most functions now do not return a text form of the item's name when returning an item link. Items for sale in guild stores can still have their names retrieved via index, so that doesn't change, but other than that...for items in your bags, bank, or guild bank, CrazyDutchGuy has mentioned you can loop through every item in every bag until you find one with a matching link and call GetItemName() once you know the bag and slot, but that seems a little...laborious...just to get an item name string. In addition, it doesn't work at all for items in the guild store sales history, since once they show up in the history they are neither in the guild store nor in the player's bags.

So, the question is this: is there any way to approximate the behavior of GetItemName() given only a new-style item link (thus allowing you to extract the textual name of an item)? ZOS obviously has something going on internally as pasting these links into the chatbox parses them fine, they work fine for tooltips, even d() parses them correctly, but I can't seem to find anything public we could use to perform that function.
  Reply With Quote
07/03/14, 03:56 AM   #2
zgrssd
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 280
Those items links in chat:
They used to have thier name extracted on the sender side. Wich had the issues that you could have a german or french item name in chat (depending on senders language settings), but a fully localized Tooltip.
Could it be that functions like "ParseItemLink" just have another return value? Perhaps something like name or "localised Name"?
  Reply With Quote
07/03/14, 05:47 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by zgrssd View Post
Those items links in chat:
They used to have thier name extracted on the sender side. Wich had the issues that you could have a german or french item name in chat (depending on senders language settings), but a fully localized Tooltip.
Could it be that functions like "ParseItemLink" just have another return value? Perhaps something like name or "localised Name"?
If you mean function ZO_LinkHandler_ParseLink(link), it is defined as follows:
Lua Code:
  1. function ZO_LinkHandler_ParseLink(link)
  2.     if type(link) == "string" then
  3.         local linkStyle, data, text = link:match("|H(.-):(.-)|h(.-)|h")
  4.         return text, linkStyle, zo_strsplit(':', data)
  5.     end
  6. end
As you can see, it doesn't have any new return value.
  Reply With Quote
07/03/14, 07:42 AM   #4
CrazyDutchGuy
 
CrazyDutchGuy's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 89
The only way, without storing anything, is checking your bag for the item based on itemlink and use the bag function GetItemName on it.

Another option is to build your own itemid database with names. Yes that sucks, but if you want itemnames on items you do not own, then that is the only option at the current state.

I had the idea once to extract the itemname from the tooltip which shows when clicking an itemlink, however that information is not reachable. It seems ZOS just kinda nuked everything, and i wouldn't be surprised if soon also the GetItemName from the bag functions get removed also.
  Reply With Quote
07/03/14, 08:43 AM   #5
Khaibit
 
Khaibit's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 26
Originally Posted by CrazyDutchGuy View Post
The only way, without storing anything, is checking your bag for the item based on itemlink and use the bag function GetItemName on it.

Another option is to build your own itemid database with names. Yes that sucks, but if you want itemnames on items you do not own, then that is the only option at the current state.

I had the idea once to extract the itemname from the tooltip which shows when clicking an itemlink, however that information is not reachable. It seems ZOS just kinda nuked everything, and i wouldn't be surprised if soon also the GetItemName from the bag functions get removed also.
Yeah, that's where I'm at right now, although I'm still trying random things. It really sucks because I'm finishing up a replacement for Awesomebilly's Luminary Trade Sales History, and because I cannot get plain text versions of item names, searching the sales history is impossible and I cannot use the center announce object to do sales alerts because (unlike the chat box, edit box, tooltips, d(), and nearly everything else), the center announce object doesn't parse those links (Awesomebilly had to parse the item link and quality, manually color the plain text name the right color and insert it appropriately to even get that to work pre-1.2.3). Oh well, it's not for lack of trying, I've probably spent 30 hours in the last week trying to get a text representation of an item retrieved from the sales history with GetGuildEventInfo() before giving up and posting here. It's just frustrating because there's *obviously* a private function that does exactly what I need - several core UI elements use it. >.<
  Reply With Quote
07/03/14, 09:30 AM   #6
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Khaibit View Post
Yeah, that's where I'm at right now, although I'm still trying random things. It really sucks because I'm finishing up a replacement for Awesomebilly's Luminary Trade Sales History, and because I cannot get plain text versions of item names, searching the sales history is impossible and I cannot use the center announce object to do sales alerts because (unlike the chat box, edit box, tooltips, d(), and nearly everything else), the center announce object doesn't parse those links (Awesomebilly had to parse the item link and quality, manually color the plain text name the right color and insert it appropriately to even get that to work pre-1.2.3). Oh well, it's not for lack of trying, I've probably spent 30 hours in the last week trying to get a text representation of an item retrieved from the sales history with GetGuildEventInfo() before giving up and posting here. It's just frustrating because there's *obviously* a private function that does exactly what I need - several core UI elements use it. >.<
Center screen announce displays links correctly, just try:
Code:
/script CENTER_SCREEN_ANNOUNCE:DisplayMessage(CSA_EVENT_SMALL_TEXT, SOUNDS.MESSAGE_BROADCAST, GetItemLink(1,1))
  Reply With Quote
07/03/14, 09:42 AM   #7
Khaibit
 
Khaibit's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2014
Posts: 26
Originally Posted by Garkin View Post
Center screen announce displays links correctly, just try:
Code:
/script CENTER_SCREEN_ANNOUNCE:DisplayMessage(CSA_EVENT_SMALL_TEXT, SOUNDS.MESSAGE_BROADCAST, GetItemLink(1,1))
Hrm, maybe I was mangling them somewhere, I was just getting raw link data output to the announce object when I tried it earlier this week. I'll take another look at it, thanks Garkin!

Edit: It would seem I wasn't mangling the links. It just doesn't work with CSA_EVENT_LARGE_TEXT. CSA_EVENT_SMALL_TEXT parses the links just fine though

Last edited by Khaibit : 07/03/14 at 09:54 AM.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Extracting string item names from links post-1.2.3?


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