def METHOD_NAME(self) -> str:
    output_str = ""
    # header
    output_str += "# openage terrain definition file\n\n"
    # version
    output_str += f"version {FORMAT_VERSION}\n\n"
    # texture files
    for texture in self.texture_files.values():
        output_str += f"texture {texture['texture_id']} \"{texture['filename']}\"\n"
    output_str += "\n"
    # blendtable reference
    output_str += f"blendtable {self.blendtable['table_id']} {self.blendtable['filename']}\n\n"
    # scale factor
    output_str += f"scalefactor {self.scalefactor}\n\n"
    # layer definitions
    for layer in self.layers.values():
        output_str += f"layer {layer['layer_id']}"
        if layer["mode"]:
            output_str += f" mode={layer['mode'].value}"
        if layer["position"]:
            output_str += f" position={layer['position']}"
        if layer["time_per_frame"]:
            output_str += f" time_per_frame={layer['time_per_frame']}"
        if layer["replay_delay"]:
            output_str += f" replay_delay={layer['replay_delay']}"
        output_str += "\n"
    output_str += "\n"
    # frame definitions
    for frame in self.frames:
        output_str += f'frame {" ".join(str(param) for param in frame.values())}\n'
    return output_str