#inspired by thepolms mapmerger script
def apply_script(protocol,connection,config):

    class Combinerprotocol(protocol):
        prev_map = None

        def on_map_change(self,map):
            print 'wait a sec'
            if self.prev_map != None:
                for x in range(512):
                    for y in range(512):
                        for z in range(63): 
                            if self.prev_map.get_solid(x,y,z):
                                map.set_point(x,y,z, self.prev_map.get_color(x,y,z))
            print 'k done'
            self.prev_map = map.copy()
            return protocol.on_map_change(self,map)

    return Combinerprotocol,connection
