script to make a pile of Zeros – pile-o-zeros.bash

I’m delving into a role playing game called Dungeon Crawl Classics Role Playing Game (DCC RPG) by Goodman Games. It’s got a unique character creation philosophy. Instead of spending a bunch of time crafting your perfect 1st level character, you create a pile of throwaway 0-level characters, sometimes called “Zeros”. Then, to kick off a campaign, you put these piles of Zeros through an introductory adventure called a “funnel”. The ones that live become 1st level characters you can become more attached to. Mortality is high in DCC, especially for Zeros. That’s why you make a lot of them. Often, a player will go through his first 3 or 4 Zeros in the first session, and the judge (what DCC calls a DM) can give him or her more. It’s sorta like Paranoid, in a way. High fun, high death rates. TPKs are not uncommon.

Well, the fine people at Purple Sorcerer wrote a web app that generates Zeros, four at a time. Then you can print out this page of four Zeros, cut them up, and then enter the funnel. Well, I’m prepping to run a funnel adventure at a local game shop, and so I’m going to need a lot of Zeros, like 50 to 70 of them. But I didn’t want to hassle with generating them on the Purple Sorcerer website one page at a time. So I wrote this little script.

It’s a bash script, and it only runs on a relatively recent Mac that’s on the internet. But it works for me, and so I’m putting here in case it works for you. If you run it without any command line arguments it’ll generate 20 pages of characters. That’s 80 Zeros total. Or you can specify a different number of pages as a command line option.

If you don’t know anything about using or running bash scripts on your Mac, here’s a quickstart:

1) Copy the text of the script below


#!/bin/bash
#
# This bash script will generate and download a bunch of DCC RPG 0-level character
# sheets, and then concatenate them into a single big PDF. It only works on a Mac.
#
# This only works on MacOS. Actually it only works on versions 10.4 or greater, but
# I'm going to assume that anyone with OS X is using a recent enough version.
#
# Written by Todd Bradley (todd@toddbradley.com)
# Thanks to Purple Sorcerer for the awesome character generator app
#
if [ "`uname`" != "Darwin" ]
then
	echo "This only runs on Mac OS X. Sorry."
	exit
fi

# If the user doesn't specify the number of pages, generate 20 of them.
pages=20

case "$1" in
	--help|-h)
		echo "Usage: $0 [N] where N is the number of pages of characters you want."
		exit
		;;
	*)
		pages=$1
		;;
esac

echo "Now generating ${pages} pages of characters, 4 to a page."

for i in `seq 1 ${pages}`;
do
	curl -# -o sheet.${i}.pdf "http://purplesorcerer.com/create.php?oc=rulebook&hp=normal&mode=3d6"
done

"/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" -o dcc-zeros.pdf sheet.*.pdf

rm sheet.*.pdf
echo "Your ${pages} pages of character sheets are now in the file dcc-zeros.pdf"
open dcc-zeros.pdf

2) Open Terminal

3) Type the following at the Terminal prompt

cd ~
cat > pile-o-zeros.bash

4) Now paste in the text you copied, and hit Ctrl+D

5) You should have the command prompt back, so type: chmod +x pile-o-zeros.bash

6) Now you can run it, with a command like this:

./pile-o-zeros.bash

or

./pile-o-zeros.bash 4

It’ll build the number of pages of Zeros that you specify, concatenate them into one big PDF, and open that in Preview.

3 thoughts on “script to make a pile of Zeros – pile-o-zeros.bash

  1. John

    If you replace the pdf combiner line with:
    “gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=dcc-zeros.pdf sheet.*.pdf”
    then it should work on linux (or any machine with ghostscript, in theory )
    Ghostscript should be available on OSX, also.

    Reply

Leave a Reply