see Rob’s tutorial here: http://coronalabs.com/blog/2014/08/12/tutorial-building-a-level-selection-scene/
the key is to set up your data in an array that can be looped over - that should eliminate the code replication.
another convenience thing i like to do is set up a sprite sequence with: locked,0,1,2,3stars
with an instance of that sprite in each level group, it’s easy to set its frame to indicate the state of that level
(Rob’s tutorial draws stuff manually, but I think that’s only so it’s more stand-alone code, not dependent on images - the concepts are still the same tho)