It's all done in various loops, so it appears to happen at once. You could do the same with yours. Put the mining code into a repeat or while condition.
I made it a long time ago and it was never finished or improved, i'm not sure where the .capx is now, and it was before tilemap support, but here are a couple of the articles you might find interesting.
https://gillesleblanc.wordpress.com/2012/10/16/creating-a-random-2d-game-world-map/
http://www.nolithius.com/game-development/world-generation-breakdown
Basically i created my own height map and set each height as a different layer of terrain, so the lowest height would be water, then sand, then land, then mountains etc.
Maybe you can do a better job. It something i'd like to revisit and have another go at eventually.