# only works for array-type tables with no "holes" in them.
For anything else you need an iterator and a counter variable using pairs()
Edit: Reference:
http://www.lua.org/manual/5.2/manual.html#3.4.6
Edit2: For your other questions:
http://www.lua.org/manual/5.2/manual.html#6.5