View Single Post
Old 05-13-2007, 06:44 AM   #39
the S layer
Re: Tutorials and resources thread
I just found a little python script i whipped together because there weren't any good GRP tools (that i know of) for Linux when i was attempting to do a little modelling. It requires the python imaging libraryand python, of course. I thought i'd post it here in case somebody finds it useful.

I thought about modifying it to "auto-generate" maphacks by comparing the original map with one modified in build or something, but nothing came out of that. Anyways, here is the help text of the script - it should give a good idea about its current capabilities

Code:
Basic usage:
  sniffgrp.py actions [grpfile]
Where actions is one or more of the following:

  -h, --help     Display this text, the only action which does
                 not require grpfile to be specified.

  -l, --list     List files in grpfile. This action takes an
                 argument, which is a normal file filter, for
                 example '*.art'. Since most shells have
                 globbing functions to expand such filters to
                 files in the current directory, quoting the
                 argument may be necessary. Several filters can
                 be given with comma separation.
      Examples:
                 List all map files in duke3d.grp:
                   sniffgrp.py -l '*.map' duke3d.grp
                 Another way of doing the same thing:
                   sniffgrp.py --list=*.map duke3d.grp
                 List all midi and voc files in duke3d.grp
                   sniffgrp.py -l '*.mid,*.voc' duke3d.grp

  -a, --list-all Lists all files in grpfile. This is basically
                 a shortcut for sniffgrp.py -l * myfile.grp

  -x, --extract  Extract files from grpfile. The argument is a
                 filter-list in the exact same style as the -l
                 action.      Examples:
                 Extract palette.dat from duke3d.grp:
                   sniffgrp.py -x palette.dat duke3d.grp
                 Extract all files from duke3d.grp:
                   sniffgrp.py -x '*' duke3d.grp

  -c, --cat      Write file contents to standard output.
                 As argument, give the file in grpfile to write.
                 Arguments to this action can not contain
                 wildcards.
      Examples:
                 Display defs.con from duke3d.grp in the console
                   sniffgrp.py -c defs.con duke3d.grp
                 A way of extracting tiles000.art to mytiles.art
                   sniffgrp.py -c tiles000.art > mytiles.art

 -f, --find     Finds all references to an art tile in the maps
                contained within grpfile. The argument is the
                tile number of the tile to search for.
      Examples:
                Find all instances of tile 100 (atomic health in
                Duke3d) within the maps in duke3d.grp
                   sniffgrp.py -f 100 duke3d.grp
                Do the same as above, and store in results.txt
                   sniffgrp.py -f 100 duke3d.grp > results.txt

 -t, --tile     Extract an art tile from grpfile into an image
                file. The parameter to this action is a tile
                number, a set of tile numbers separated by comma,
                or one or more tile-ranges. Clarified in examples.

                As additional option, you can specify the format
                of the output files. The default is PNG. Use one
                of the following as an additional action if you
                want another format:
                    --png (PNG output - default)
                    --gif (GIF output)
                    --bmp (BMP output)
                    --pcx (PCX output)
      Examples:
               Extract tile 100 from duke3d.grp into 100.png
                  sniffgrp.py -t 100 duke3d.grp
               Extract tiles 100 to 200 from duke3d.grp
                  sniffgrp.py -t 100-200 duke3d.grp
               Extract tiles 50, 75 and 80 as GIF from duke3d.grp
                  sniffgrp.py --gif -t 50,75,80 duke3d.grp
               Extract tiles 50-60 as well as tile 100 from duke3d.grp
                  sniffgrp.py -t 50-60,100 duke3d.grp
               Extract tiles 50-60 and 70-80 and 90-100 from
               duke3d.grp, as PCX
                  sniffgrp.py --pcx -t 50-60,70-80,90-100 duke3d.grp
Attached Files
File Type: zip sniffgrp_001.zip (7.4 KB, 4 views)
__________________
Cheers,
--the S layer
the S layer is offline