WoWInterface - View Single Post - Table > how to pick or skip values?
View Single Post
05-16-20, 09:16 AM   #2
nUI Maintainer
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,534
As with any array you either get them in order ..
Lua Code:
  1. for i = 1,5 do
  2.     print(items[i])
  3. end

or select them by index
Lua Code:
  1. print(items[10])

or select them by key if they are not in sequential index order
Lua Code:
  1. print(items["priest"])

If you want to go through a list and print certain ones you will need an additional check, using some set of if statements that will tell you if that item is the one that fits the bill. In this example the items table contains a class name to signify that item is for priests only. So if you want to print off all those items suitable for priests then you would do that test. How you would use this all depends on what information your data includes.
Lua Code:
  1. for i = 1,5 do
  2.     if items[i].class == "priest" then
  3.        print(items[i])
  4.     end
  5. end
This is a link to how tables work in lua which is the equivalent to arrays
  Reply With Quote