for k,v in ipairs(table.subtable) do
if table.contains(v, "what I am looking for") then
display(v)
end
end
itemPrices.bombs –> a table
itemPrices.booze –> a table
itemPrices.guns. –> a table
itemPrices.guns[1] –> another table
display(itemPrices.guns[1]) –> {name="Uzi", shop="The Gun Shop", price=500}
display(itemPrices.booze[11] –> {name="Yue's IPA", shop="WSBC", price=10, type="Refill from Keg"}
etc…
I have a script that pulls informations from text with regular expressions. The regexps capture certain data from given lines and save the data (as a table) in specific subtables of another table. It looks like this.
The saves look like this: (added with table.insert(mainTable.<specificsubtable>, tableOfDataToSave)
I can display all entries of a specific subtable, something like display(mainTable.subtable) which is useful in itself but lacking. What I need is an iterator func that can return specific results. Like listing every key/value pair a specific subtable that contains argument2="specifictext". I have been trying to use table.contains() or a for loop, or next,value,nil, or a mix-mash of the three to accomplish this, with no success.
Any suggestions on how to go about this. My understanding of for loops just isn't there. I can iterate through mainTable.subtable and return results, but it is usually a mem address of the subtable. That's not what I want.