Download
(15Kb)
Download
Updated: 01-25-23 10:52 PM
Compatibility:
Dragonflight patch (10.0.5)
Updated:01-25-23 10:52 PM
Created:04-27-22 11:40 PM
Downloads:114
Favorites:0
MD5:

LibNPCInfo

Version: v1.004
by: fang2hou [More]

* Introduction
Cause Blizzard do not provide an API for retrieving information about NPCs, this library is created to help you retrieve information about any NPC with its ID.

The algorithm behind this library is simple:

  • Create a new tooltip for scanning.
  • Attempt to set the unit of the tooltip to the NPC with the ID you want to retrieve information about.
  • Scrape the NPC's information from this tooltip.

It seems Blizzard limits the rate of tooltip unit setting, or the network quality also affects. Sometimes you need to wait a bit before you can retrieve information about a NPC. Since this library already added a double check for tooltips, usually you can safely use it.

* Usage
Lua Code:
  1. local lib = LibStub("LibNPCInfo")
  2.  
  3. -- The data is stored in the following format:
  4. -- data = {
  5. --  id: number
  6. --  name: string
  7. --  desc: string
  8. -- }
  9. local function dataHandler(data)
  10.     print(format("%s, %s, %s", data.id, data.name, data.desc))
  11. end
  12.  
  13. -- Only npcID will be returned if failed
  14. local function failureHandler(npcID)
  15.     print("failed: %d", npcID)
  16. end
  17.  
  18. -- single call
  19. lib.GetNPCInfoByID(43929, dataHandler, failureHandler)
  20. -- (print by callback function)
  21. -- <<< 43929, 布靈登4000型, 等級??機械
  22.  
  23. -- multiple calls with the given ID table
  24. local list = {43929, 32510}
  25. lib.GetNPCInfoWithIDTable(list, dataHandler)
  26. -- (print by callback function)
  27. -- <<< 43929, 布靈登4000型, 等級??機械
  28. -- <<< 32510, 戰歌戰地衛士, 等級??人形生物(精英)

LibNPCInfo
v1.004 (2023-01-26)
Full Changelog Previous Releases
  • toc: bump game version to latest
Archived Files (4)
File Name
Version
Size
Author
Date
v1.003
15kB
fang2hou
11-15-22 09:02 AM
v1.001
15kB
fang2hou
05-31-22 05:01 PM
v1
16kB
fang2hou
04-28-22 12:34 AM
v0
16kB
fang2hou
04-28-22 12:28 AM


There have been no comments posted to this file.
Be the first to add one.



Category Jump:

Support AddOn Development!

You have just downloaded by the author . If you like this AddOn why not consider supporting the author? This author has set up a donation account. Donations ensure that authors can continue to develop useful tools for everyone.