View Single Post
09/23/20, 12:00 PM   #9
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,966
If the return value is nil the library most probably cannot find any data of these items, whereever it reads them from (MM, TTC data?).

A hint about the itemlinks.
Instead of redundantly re-using the same itemlink, where only the itemId changes, you could use string.format as a function.


Current:
Lua Code:
  1. var1 = "|H0:item:883:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h"
  2. var2 = "|H0:item:12345:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h"
  3. var3 = "|H0:item:99999:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h"

New:
Lua Code:
  1. local function buildItemLinkForItemId(itemId)
  2.  return string.format("|H0:item:%d:30:1:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h", tonumber(itemId))
  3. )
  4. end
  5.  
  6. var1 = buildItemLinkForItemId(883)
  7. var2 = buildItemLinkForItemId(12345)
  8. var3 = buildItemLinkForItemId("99999")
  Reply With Quote