ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   Wish List (https://www.esoui.com/forums/forumdisplay.php?f=177)
-   -   [open] item and ability link iterator (https://www.esoui.com/forums/showthread.php?t=6903)

sirinsidiator 03/15/17 12:41 PM

[open] item and ability link iterator
 
As the title says, it would be nice if we could have functions which allow us to easily iterate over all existing items or abilities without the need to filter by item name and set a hardcoded limit like this:

Lua Code:
  1. for i=1, 140000 do
  2.     local link = ("|H0:item:%d:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h"):format(i)
  3.     local name = GetItemLinkName(link)
  4.     if(name ~= "") then
  5.         -- something
  6.     end
  7. end

I'd say the simplest solution would be a function similar to GetNextMailId which returns the next valid itemId.
Lua Code:
  1. function GetNextItemLinkIter(state, itemId)
  2.     itemId = GetNextItemId(itemId)
  3.     return itemId, ("|H0:item:%d:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0:0|h|h"):format(itemId)
  4. end
  5.  
  6. for id, link in GetNextItemLinkIter do
  7.     -- something
  8. end


All times are GMT -6. The time now is 03:10 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI