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/482e78d4f0bc3ff8161e0f2f0b57ac13 to your computer and use it in GitHub Desktop.
Save Xymph/482e78d4f0bc3ff8161e0f2f0b57ac13 to your computer and use it in GitHub Desktop.
Omgifol (https://doomwiki.org/wiki/Omgifol) script to search for specific thing type in maps and show their positions; for DoomWiki.org
#!/usr/bin/python3
# search maps for things of the given type, by Frans P. de Vries (Xymph)
import sys
from omg import *
def searchmap(wad, name, thingtype):
try:
edit = UMapEditor(wad.udmfmaps[name])
except KeyError:
edit = UMapEditor(wad.maps[name])
i = 0
for thing in edit.things:
if thing.type == thingtype:
print("Found %5d:\t%6d\t%6d" % (i, thing.x, thing.y))
i += 1
if len(sys.argv) != 4:
print("\n Omgifol script: search map(s)' things for a type\n")
print(" Usage:")
print(" searchThing.py source.wad pattern type\n")
print(" Search all maps whose names match the given pattern (eg E?M4 or MAP*)")
print(" for things of the given type.")
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