Board Thread:Lua Help/@comment-24688171-20170921124719

Suppose I have a lua table as below: local data = { { ['name'] = "Piccaso", ['dob'] = "", ['pob'] = "Earth" }; { ['name'] = "Optimus Prime", ['dob'] = "", ['pob'] = "Cybertron" }; { ['name'] = "Kara Zor-El", ['dob'] = "", ['pob'] = "Krypton" }; { ['name'] = "Pennywise", ['dob'] = "", ['pob'] = "Earth" }; { ................... }; }

Now I want to create a function, which will list all the "name" value if the "pob" value is "Earth" (for example).

Sample function: function p.load(data) for i, v in ipairs(data) do       local answer = "" if data[i]['pob'] == "Earth" then answer = answer .. data[i]['name'] end end return answer end return p

The function should iterate through the tables, and read the value of "pob", if "pob" = "Earth", but the result on the page is empty... HELP! 