I have a much more basic question on tables/arrays. I understand that there are no arrays per se in Lua, and that Tables are the way to go here. I know how to create them when you have all the data ( x = { "a", "b", "c" } ).
If I wanted to create and append tables dynamically, how do I do that? Is there a very simple tutorial example somewhere that shows basic array-like table manipulation? The documentation at
www.lua.org is not very clear to me, and I was hoping there was a better example somewhere that I could look at.
Basically, what I am trying to do is a simple "If (some_case_is_true) then add 'this' to the array" (yeah, I know--tables. I'm just an old BASIC hack at heart). Basically, I don't know how big the array might grow to be (since that depends on the situation at the moment), so I need to be able to keep growing it as more data applies (between 1 and 15 rows, max). The pseudo code would look something along the simplified lines of:
counter = 1;
for x = 1, limit do
if (condition == met) then
array1[counter] = "something";
counter = counter + 1;
end
end
The questions I come up with are:
1) Are there specific commands I need to use to get a table to behave as I am intending above?
2) Are tables 0-based or 1-based?
3) If it really is a table, would a table named Table[x][y][z] mean all those elements are on the same row (three columns on the row), or are they behaving like dimensions (for the combination of a specific [x] and [y], there are a theoretically unlimited number of [z]s).
I kind of understand the discussion above, but since I've pretty much worked with programming using arrays (except for SQL/database programming), I'm not sure I'm understanding how they are implemented here in Lua. Any simple pointers or examples would be most useful.