Thread Tools Display Modes
09/02/14, 09:29 PM   #1
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Book table ?

Hello,

When someone link a book, game use function

Lua Code:
  1. link = ZO_LinkHandler_CreateChatLink(GetLoreBookLink, categoryIndex, collectionIndex, bookIndex)

Where 1rst arg is the fuction itself, aka GetLoreBookLink
Lua Code:
  1. GetLoreBookLink(categoryIndex, collectionIndex, bookIndex)

then it send the link to the chat

But, the link itself is a bit problematic for one of my needs..

cause if you copy the link to your notepad, or whatever, the link will be (ex):

|H1:book:159|h|h
Here, i can recognize the linkhandler format and the internal bookid of the game - 159 (wich is Aedra and Daedra) .. and .. I would like to get the book name.

But impossible to find any trick in the whole game, or LORE_LIBRARY table, or whatever .. is there any people started some researchs here ? I only got the book ID to work or pass as argument, and nothing more.

I searched in few addons code but they all use GetLoreBookLink(categoryIndex, collectionIndex, bookIndex, linkStyle) .. that i cannot access to.

I've also tried to find how the tooltip of the book work and nothing more (because when you clic on the tooltip, game can translate book[159] into "Aedra and Daedra" (and informs you if you know it too!), nothing interesting here too..

PS : I also to hack itemhandler but (per exemple) item 159 does not exist, seems books and items are not reallyon the same table

so if anyone found some interesting things, , thanks in advance !
  Reply With Quote
09/03/14, 05:43 AM   #2
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
I'd try building a lookup table. Iterate all categories, collections, books, and store books[id] = {catIndex, colIndex, bookIndex}.
  Reply With Quote
09/03/14, 05:44 AM   #3
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Ayantir View Post
Hello,

When someone link a book, game use function

Lua Code:
  1. link = ZO_LinkHandler_CreateChatLink(GetLoreBookLink, categoryIndex, collectionIndex, bookIndex)

Where 1rst arg is the fuction itself, aka GetLoreBookLink
Lua Code:
  1. GetLoreBookLink(categoryIndex, collectionIndex, bookIndex)

then it send the link to the chat

But, the link itself is a bit problematic for one of my needs..

cause if you copy the link to your notepad, or whatever, the link will be (ex):



Here, i can recognize the linkhandler format and the internal bookid of the game - 159 (wich is Aedra and Daedra) .. and .. I would like to get the book name.

But impossible to find any trick in the whole game, or LORE_LIBRARY table, or whatever .. is there any people started some researchs here ? I only got the book ID to work or pass as argument, and nothing more.

I searched in few addons code but they all use GetLoreBookLink(categoryIndex, collectionIndex, bookIndex, linkStyle) .. that i cannot access to.

I've also tried to find how the tooltip of the book work and nothing more (because when you clic on the tooltip, game can translate book[159] into "Aedra and Daedra" (and informs you if you know it too!), nothing interesting here too..

PS : I also to hack itemhandler but (per exemple) item 159 does not exist, seems books and items are not reallyon the same table

so if anyone found some interesting things, , thanks in advance !
FYI: Book 159 is Triumphs of a Monarch, Ch. 10, Aedra and Daedra is 163 (see number in the URL).

I didn't find any function which can translate book number to the title, so the only way is creating lookup table:
Lua Code:
  1. local BOOKSHELF = {}
  2.  
  3. for categoryID = 1, GetNumLoreCategories() do
  4.    local _, numCollections = GetLoreCategoryInfo(categoryID)
  5.  
  6.    for collectionID = 1, numCollections do
  7.       local _, _, _, numBooks = GetLoreCollectionInfo(categoryID, collectionID)
  8.       for bookID = 1, numBooks do
  9.          local title = GetLoreBookInfo(categoryID, collectionID, bookID)
  10.          local bookNumber = tonumber((select(4, ZO_LinkHandler_ParseLink(GetLoreBookLink(categoryID, collectionID, bookID, LINK_STYLE_DEFAULT)))))
  11.          BOOKSHELF[bookNumber] = title
  12.       end
  13.    end
  14. end
Creating of this table is pretty fast, so I think it is not a big deal to make it in EVENT_ADD_ON_LOADED event handler.


Last edited by Garkin : 09/03/14 at 07:24 AM. Reason: added extra parenthesis to get rid of extra return values
  Reply With Quote
09/03/14, 07:16 AM   #4
merlight
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 671
Originally Posted by Garkin View Post
local bookNumber = tonumber(select(4, ZO_LinkHandler_ParseLink(GetLoreBookLink(categoryID, collectionID, bookID, LINK_STYLE_DEFAULT))))
Careful with tonumber & select. Every now and again I run into a crazy bug when I do this. tonumber(x, base) takes an optional base argument, and select(4, ...) returns all after the 4th. You want to wrap that select in another pair of parentheses tonumber((select(4, ...))), or explicitly specify decimal base tonumber(select(4, ...), 10)
  Reply With Quote
09/03/14, 07:23 AM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by merlight View Post
Careful with tonumber & select. Every now and again I run into a crazy bug when I do this. tonumber(x, base) takes an optional base argument, and select(4, ...) returns all after the 4th. You want to wrap that select in another pair of parentheses tonumber((select(4, ...))), or explicitly specify decimal base tonumber(select(4, ...), 10)
Ok, I will add extra parenthesis so return value will be just one.
  Reply With Quote
09/03/14, 08:58 AM   #6
Ayantir
 
Ayantir's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2014
Posts: 1,019
Thanks for your answers, i didn't want to integrate such code with a raw dump but yes, with a table created when addon loads , it's clearly correct for me

the answer is so arg4 returned by GetLoreBookLink(), many thanks
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Book table ?


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