Ah ok, not gonna write that for you, but here is an example.
position_list = []
def build(cont):
own = cont.owner
spawner = own.scene.objects['spawner']
if not position_list:
add_object(cont,spawner)
return
if not spawner.worldPosition in position_list:
add_object(cont,spawner)
def add_object(cont,spawner):
own = cont.owner
last_added = own.scene.addObject('Cube',spawner,0)
position_list.append(last_added.worldPosition)
spawner.worldPosition.y += 1.0
in this case, the list only stores location of the cubes you have spawned, so you can use it later.
but this is basically the basics to add cubes in a straight line.
You can add an in range() check to add squares, but to keep it around the player is a completely other story.
best is to look into resources, should be some scripts there ready to go. for example: dig world problem