View Single Post
04/28/15, 06:23 PM   #19
circonian
AddOn Author - Click to view addons
Join Date: May 2014
Posts: 613
Originally Posted by stAjora View Post
Thanks for the info. I got it working perfectly. Now I have a new issue where I have a few nested tables and at the end is a boolean, I ca'nt seem to check this value.
Code:
for key, value in pairs(table.table2.table3) do
    if(value == true) then
        d('true')
    elseif(value == false) then
        d('false')
     end
end
I may be missunderstanding, but from the way you phrased it, is the boolean the only value in table3 ?
Do you know the name of the boolean? like:
Lua Code:
  1. table = {
  2.   table2 = {
  3.    table3 = {
  4.       booleanIWantToCheck = true,
  5.    }
  6.   }
  7. }
  8. -- If so then you can check it with:
  9. if table.table2.table3.booleanIWantToCheck == true then
  10.    -- do whatever
  11. end

Using paris loops through every object in table 3, which is probably not what you want.
Like if you had:
Lua Code:
  1. table = {
  2.   table2 = {
  3.    table3 = {
  4.       otherBoolean = true
  5.       booleanIWantToCheck = false,
  6.       someString = "hello",
  7.    }
  8.   }
  9. }
using pairs(..) like you did would loop through all of those values: otherBoolean , booleanIWantToCheck , someString checking if each one is true or false.
  Reply With Quote