Level Editors using TileSet pngs/jpgs

I have been peering at the artwork available over at OpenGameArt and there are lots of tilesets. I’ve been thinking about how I might go about designing a level editor based on image:copy() where you use a rectangle to select a single tile from the big tileset png. Has anyone created anything like this? I know the demo project for drawing sprites had an export function which gave you the lua code used to draw whatever you had drawn in the editor. I’d be trying to use a similar system, where something like “sprite( getTile( bigImage, selectionRect ), X, Y)” is written into a tab. I’m still just flushing out ideas in my head tho. any suggestions where to start?

Also, does anyone have a tutorial for how to make large maps scrollable?

There was a lot of discussion a year or two ago about making and using tilesets, see if you can find it.

Rather than write out Lua code, I suggest writing out a table of image names and positions, then having a separate function that reads everything in the table into memory (ie write out data rather than code).