Skip to content

Instantly share code, notes, and snippets.

@Xymph
Last active August 21, 2022 10:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xymph/3bc2f07a4d841e085dadca62df60fc44 to your computer and use it in GitHub Desktop.
Save Xymph/3bc2f07a4d841e085dadca62df60fc44 to your computer and use it in GitHub Desktop.
Omgifol (https://doomwiki.org/wiki/Omgifol) script to search for a sector in maps and show its sidedefs & linedefs; for DoomWiki.org
#!/usr/bin/python3
# search maps for a sector's sidedefs/linedefs, by Frans P. de Vries (Xymph)
import sys
from omg import *
def searchmap(wad, name, thesector):
try:
edit = UMapEditor(wad.udmfmaps[name])
except KeyError:
edit = UMapEditor(wad.maps[name])
i = 0
for sector in edit.sectors:
if i == thesector:
print("Found sector %d: type %d id %d" % (thesector, sector.special, sector.id))
i += 1
i = 0
for sidedef in edit.sidedefs:
if sidedef.sector == thesector:
j = 0
for linedef in edit.linedefs:
if linedef.sidefront == i or linedef.sideback == i:
break;
j += 1
print(" sidedef %d linedef %d" % (i, j))
i += 1
if len(sys.argv) != 4:
print("\n Omgifol script: search map(s)' sector and its sidedefs/linedefs\n")
print(" Usage:")
print(" searchSector.py source.wad pattern sector")
print(" Examples:")
print(" Search all maps whose names match the given pattern (eg E?M4 or MAP*)")
print(" for the sector's sidedefs and linedefs.")
else:
# load WAD and draw map(s)
print("Loading %s..." % sys.argv[1])
inwad = WAD()
inwad.from_file(sys.argv[1])
for name in inwad.maps.find(sys.argv[2]) + inwad.udmfmaps.find(sys.argv[2]):
print("Searching %s" % name)
searchmap(inwad, name, int(sys.argv[3]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment