Thread: Book table ?
View Single Post
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