Implementing c-style for loop in lua