Posted 30 July 2015 - 07:48 PM
I am looking to write a function to search through a pre-made table and pull out the related data and was thinking of using a while loop to search through each entry of the table:
First of all, I am new to Lua and pretty new to programming in general, would this code work?
Second, is there a hard-coded way/api/method to search through arrays/tables?
Thanks in advance!
local function searchTable(searchTerm)
i = 0
local finished = false
while finished ~= true do
i = i +1
if table[i][3] == "searchTerm" then
item1 = table[i][2]
item2 = table[i][4]
return item1, item 2
finished = true
end
end
First of all, I am new to Lua and pretty new to programming in general, would this code work?
Second, is there a hard-coded way/api/method to search through arrays/tables?
Thanks in advance!
Edited on 30 July 2015 - 05:50 PM