diff --git a/README.rst b/README.rst index 542f2c4..dd77116 100644 --- a/README.rst +++ b/README.rst @@ -123,7 +123,7 @@ Running ------- To generate a set of Google Map tiles, use the gmap.py script like this:: - python gmap.py [OPTIONS] + python gmap.py [OPTIONS] The output directory will be created if it doesn't exist. This will generate a set of image tiles for your world in the directory you choose. When it's done, diff --git a/gmap.py b/gmap.py index 51d97bc..9a8cd52 100755 --- a/gmap.py +++ b/gmap.py @@ -36,8 +36,8 @@ import world import quadtree helptext = """ -%prog [OPTIONS] -%prog -d [tiles dest dir]""" +%prog [OPTIONS] +%prog -d [tiles dest dir]""" def main(): try: @@ -69,11 +69,21 @@ def main(): worlddir = args[0] if not os.path.exists(worlddir): + # world given is either world number, or name try: worldnum = int(worlddir) worlddir = world.get_worlds()[worldnum]['path'] - except (ValueError, KeyError): - print "Invalid world number or directory" + except ValueError: + # it wasn't a number, try using it as a name + worlddir = os.path.join(world.get_save_dir(), worlddir) + if not os.path.exists(worlddir): + # still doesn't exist! print help and die. + print "Invalid world name or path" + parser.print_help() + sys.exit(1) + except KeyError: + # it was an invalid number + print "Invalid world number" parser.print_help() sys.exit(1)