View Single Post
05/30/14, 08:38 AM   #17
lyravega
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 93
You don't need for loops to find if something exists in a table if you are not using an array. As long as it is a table, you can use keys like values to check if something exists and work from there. If you are not going to do table-to-table operations, or an operation that HAS to go through all the elements in a table (for example, counting), then you really don't need for loops for them.

http://www.esoui.com/forums/showthre...=8802#post8802

Code:
woodworking = {
    ["en"] = {
        ["Ashtree"] = true,
        ["Beech"] = true,
        ["Birch"] = true,
        ["Hickory"] = true,
        ["Mahogany"] = true,
        ["Maple"] = true,
        ["Nightwood"] = true,
        ["Oak"] = true,
        ["Yew"] = true,
    },
}
Now, all these will return true:

Code:
if woodworking
if woodworking.en
if woodworking.en.Ashtree
local TEST = "Ashtree"; if woodworking.en[TEST]
The last one is a special case; unless you use [] it will look for a key named TEST rather than a key named TEST's value.

Last edited by lyravega : 05/30/14 at 09:03 AM.
  Reply With Quote