Pulling my hair with LUA
If I have this structure
mydata = { "one", "two", "three", "four" };
How do I iterate through it? How do I add a value if I want to?
I am thinking of iterating like mydate[1], mydata[2] etc but the for loop syntax confuses me.
In C it might look like this
for i = 1, 50 do
if ( mydata[i] == somevalue ) then return/break/whatever; -- we already have it
end
if ( i == 51 ) then ... -- we do not have it, add it
mydata[51] = somevalue;
end
I am not intending to remove just to add and then at some time wipe the lot and start again.
|