This is my first time posting there, so I will make this post short.
I made an automatically mining turtle yesterday, and found that I need a way to store visited blocks, without knowing the size of the area I excavate. A well known solution popped into my mind: an octree
I would not like to expain its inner workings, but in sort, it is a three dimensional (in this case infinite) "array", where you can store values, in any shape, efficently.
In my implementation, I added a few tweaks, such as the octree can grow as big as you want it, without any side effects.
Basically, this data structure allows you to store data in an "infinite" three dimensional "array", without having to worry about resizing, or reallocating lua tables.
For further information about the data structure, take a look at the wiki page of octrees.
You can access the code here: https://gist.github.com/4587030
Almost forgot, the api:
tree = octree.new()
tree:get( x, y, z ) - Returns the previously set value, or nil
tree:set( x, y, z, value ) - Self explanatory