1. Ed Blake
  2. df_turtle


A Python module for generating Dwarf Fortress macros using turtle like syntax.

    python >= 2.4

Developed and tested under OSX 10.6, Python 2.6, using Macvim 7.3!

    Write a python script that imports df_turtle and instantiate a
    df_turtle.Turtle with the filename of the macro you want created.
    Issue commands by calling methods on the turtle. Call turtle.finish() to
    finish writing the macro file. Run your script to generate your macros.
    It is up to you to get the *.mak file into the Dwarf Fortress macro
    directory. The macros should be located in your df folder under
    data > init > macros. I suggest either handling the macro folder path
    in your script (see housing_01.py for an example) or more simply just
    put the module and your scripts in the macro folder.

    Note that DwarfFort will not reload your macro once it is open.
    While testing you will need to go to esc > keybindings > macros
    and delete any macros you want to replace. The files in the macros
    directory will be deleted immediately and permanently so be careful!
    If you mark a macro file readonly/protected it will not be deleted and
    you can make a macro to delete macros. Put these together and you can
    make a delete all macros macro that wont delete itself...

    See housing_01.py for an okay example script that generates a lousy
    housing pattern!

    # DF commands
    # These are different menus/modes in DF.
    # You must be in the mode before using a macro, and you cannot switch mode.
    designate(cmd): Set the current drawing mode.
        This is only for the dig/designate mode.
    build(cmd, extras): Issue a build order at the current location.
        Extras are things like WxH for constructions or list navigation
    place(cmd): Set type of pile for placing.
        This is like dig mode, except use of the line and
        circle modes would be sub-optimal
    query(cmds): A list of query commands to preform at current tile.

    # Bearings
    north(): Face north.
    east(): Face east.
    south(): Face south.
    west(): Face west.
    left(): Turn to the direction left of self.bearing.
    right(): Turn to the direction right of self.bearing.
    reverse(): Face in direction opposite of current bearing.

    # Movement
    home(): Move back to start location.
    move(forward, right, up=0): Move forward and right from current position.
    go(steps=1): Move along current bearing.
    up(steps=1): Move up z level.
    down(steps=1): Move down z level.

    # Drawing
    penDown(): Draw in every cell we touch.
    penUp(): Don't draw in cells we touch.
    point(): Draw at current location.
        Used in designate and place modes, use special commands for build/query.
    rect(forward, right, up=0): Draw a rectangle from current location.
    line(forward, right): Draw a line from current location.
        Use Bresenham line algorithm
    polyline(points, closed=False): Draw a series of connected lines.
    shape(points): Draw an arbitrary filled area (NotImplimented).
    arc(radius, start, end): Draw a circular arc around current location.
        Use midpoint circle algorithm (NotImplimented).

    Clean up and finish building commands.
    Add stockpile customization.
    Impliment query mode (for designating rooms).
    Finish shape and arc drawing commands.
    Write a "parser" to accept a minimal command syntax.
    Write some L-system tools and examples using the above syntax.
    Write at least one pre-visualizer (pygame, Vpython, Blender, ???).
    A test suite would be nice.
    More examples.
    Steal ideas from quickfort.
    Try to use dfhack...