I've been trying this for a while.
So I have a table that looks like this:
1 | { "ITEM1" , "ITEM2" } |
I'm attempting to one of these values but I am not sure how I should go about it. Any help?
The code example you provided is an array table, the index would be 1 and 2 (sequential integers). If you want to find out if a value is in the table you'll need to iterate the table and compare the values to the one you're looking for.
1 | local t = { "ITEM1" , "ITEM2" } |
2 | for index, value in ipairs (t) do |
3 | if value = = "ITEM2" then -- let's say I want to find "ITEM2" |
4 | print (value .. " found at index " .. index) |
5 | return index |
6 | end |
7 | end |