Skip to content

Instantly share code, notes, and snippets.

@devnoot
Last active March 28, 2024 03:56
Show Gist options
  • Save devnoot/523689a7cbacf894c7014204b84356eb to your computer and use it in GitHub Desktop.
Save devnoot/523689a7cbacf894c7014204b84356eb to your computer and use it in GitHub Desktop.
Python script that converts Doom wads to UDMF format. Each map in the provided wad is saved separately.
# Script to convert Doom WAD to UDMF
import argparse
import os
from omg import WAD, UMapEditor
def parse_args():
parser = argparse.ArgumentParser(description='Convert Doom WAD files to UDMF format.')
parser.add_argument('--input', required=True, help='Path to the input WAD file')
return parser.parse_args()
def convert_wad_to_udmf(input_wad, key, output_udmf_path):
map_editor = UMapEditor(input_wad.maps[key])
textmap = map_editor.to_textmap()
with open(output_udmf_path, 'w') as udmf_file:
udmf_file.write(textmap)
def main():
args = parse_args()
inwad = WAD(args.input)
for k in list(inwad.maps.keys()):
print(f'Converting {k}')
convert_wad_to_udmf(inwad, k, f'{os.path.splitext(os.path.basename(args.input))[0]}_{k}.udmf')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment