v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "40d:Macros and keymaps"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
m (Rule G)
 
(32 intermediate revisions by 23 users not shown)
Line 1: Line 1:
Playing Dwarf Fortress means lots of typing.  Although the game (as of version v0.27.176.38c) has no internal macro/keymap system, using an external program can save you a great deal of time when dumping, rewalling, designating, and so forth.
+
{{Quality|Superior|11:05, 18 May 2015 (UTC)}}
 +
{{av}}
 +
Playing Dwarf Fortress means lots of typing.  Although the game has no internal macro/keymap system (except in alpha version 40d12), using an external program can save you a great deal of time when dumping, rewalling, designating, and so forth.
  
 
#  Go to [[Utilities#AutoHotKey]] and download AutoHotKey.  Installation is simple and the program uses few system resources.
 
#  Go to [[Utilities#AutoHotKey]] and download AutoHotKey.  Installation is simple and the program uses few system resources.
Line 8: Line 10:
 
Users may experience some issues in getting scripts to work, particularly when using looping scripts when experiencing low frame-rates.
 
Users may experience some issues in getting scripts to work, particularly when using looping scripts when experiencing low frame-rates.
 
* If experiencing low frame-rates, try adding delays ("Sleep 100" to pause for 100 milliseconds for example) within loops to allow the interface to keep up. If there are nested loops, sometimes adding a pause at the end of an inner loop is all that is needed to flush the keyboard buffer
 
* If experiencing low frame-rates, try adding delays ("Sleep 100" to pause for 100 milliseconds for example) within loops to allow the interface to keep up. If there are nested loops, sometimes adding a pause at the end of an inner loop is all that is needed to flush the keyboard buffer
 +
* Another way to add delay during and after each simulated key press is to put <B>SetKeyDelay, 40, 40</B> at the start of the macro.
 
* Make sure that Dwarf Fortress maintains focus. IM windows are the enemy! Who needs friends anyhow? You've got Dwarf Fortress.
 
* Make sure that Dwarf Fortress maintains focus. IM windows are the enemy! Who needs friends anyhow? You've got Dwarf Fortress.
 
* This may go without saying, but most macros assume standard key-mappings. If you're using non-standard ones, you may have to edit the macro to get it to work.
 
* This may go without saying, but most macros assume standard key-mappings. If you're using non-standard ones, you may have to edit the macro to get it to work.
 
* Visiting liaisons can bring up screens that eat keystrokes, throwing a long-looping script out-of-phase with where it expects the game to be.  Wait for the farewell screen before running a long script.
 
* Visiting liaisons can bring up screens that eat keystrokes, throwing a long-looping script out-of-phase with where it expects the game to be.  Wait for the farewell screen before running a long script.
 
* The <B>SendPlay</B> function supports keys that the <B>Send</B> function does not, for example {{key|Shift-Enter}}.  According to the AutoHotKey documentation, <B>SendPlay</B> may also be better at preventing dropped keystrokes.
 
* The <B>SendPlay</B> function supports keys that the <B>Send</B> function does not, for example {{key|Shift-Enter}}.  According to the AutoHotKey documentation, <B>SendPlay</B> may also be better at preventing dropped keystrokes.
 +
 +
== [http://sun2design.com/quickfort/ Quickfort] ==
 +
 +
Quickfort is an AutoHotkey-based utility for Dwarf Fortress that helps you build fortresses from "blueprint" .CSV files (comma separated values). These files are easily created and edited in an app like Excel. Most building-oriented DF commands are supported through the use of multiple .CSV files to describe the different phases of DF construction (designation, building, stockpiles, and making adjustments). Many of the examples below can be reproduced in Quickfort.
 +
 +
 +
== Built-in Macros ==
 +
 +
With the release of df_28_181_40d13, Dwarf Fortress supports macros without any outside program. They can be created by hitting escape to access the options menu and choosing the Key Bindings section. Once in the Key Bindings menu hit Shift+Tab to open the macro screen. The macros you create here are saved in the file "\data\init\interface.txt". Adding the following to the end of that file will create a macro that selects every item on the trade screen when you hit the tilde key (`).
 +
 +
<pre>
 +
[BIND:MACRO0]
 +
[SYM:`]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:STANDARDSCROLL_DOWN:1]
 +
</pre>
 +
 +
Performance can be increased by changing the macro pause, MACRO_MS, from the default 150ms per command to zero.  Most dig macros can be created using combinations of the following:
 +
<pre>
 +
[MACRO:CURSOR_UP:1]
 +
[MACRO:CURSOR_DOWN:1]
 +
[MACRO:CURSOR_LEFT:1]
 +
[MACRO:CURSOR_RIGHT:1]
 +
[MACRO:SELECT:1]
 +
[MACRO:DESIGNATE_DIG:1]
 +
[MACRO:DESIGNATE_UNDO:1]
 +
[MACRO:CURSOR_UP_FAST:1]
 +
[MACRO:CURSOR_DOWN_FAST:1]
 +
[MACRO:CURSOR_LEFT_FAST:1]
 +
[MACRO:CURSOR_RIGHT_FAST:1]
 +
[MACRO:MACRO123:1]
 +
</pre>
 +
Most of these should be self-explanatory. Each command is followed with a quantity.  To call other macros, use <pre>[MACRO:MACRO###:1]</pre> Each new macro begins with a bind command, consisting of BIND, the macro number, and a description:
 +
<pre>[BIND:MACRO11:dig_round_room]</pre>  Spaces are not allowed in the description{{verify}}.  To bind this macro to a key, SYM is used.<pre>[SYM:Ctrl+Right]</pre> Ctrl, Alt, and Shift combinations are allowed, but not chords with more than one{{verify}}, like Ctrl+Shift+Right.  Also, the windows, or meta key, does not appear to be supported{{verify}}. Macros appear to only be terminated by the start of a new macro (BIND command) or the end of the interface.txt file.
 +
 +
Visit this [http://www.bay12games.com/forum/index.php?topic=40751.0 forum post] for additional macros, and discussion on macro creation.
  
 
== AutoHotKey Examples ==
 
== AutoHotKey Examples ==
  
 
===Dumping===
 
===Dumping===
 +
 +
====[[GuiDumper.ahk]]====
 +
This script allows the user to specify a range of squares to dump.
 +
 
====Stock Screen Dump====
 
====Stock Screen Dump====
 
Taken from an old version of [[User:Jackard|Jackard's user page]].
 
Taken from an old version of [[User:Jackard|Jackard's user page]].
  
To use, first have your bookeeper do enough desk work so you can view individual items in the stocks listing.  Then bring it up and press del to quickly mark stuff.  To adjust the key repeat rate, edit the KEY_HOLD_MS value in \data\init\init.txt.
+
To use, first have your bookkeeper do enough desk work so you can view individual items in the stocks listing.  Then bring it up and press del to quickly mark stuff.  To adjust the key repeat rate, edit the KEY_HOLD_MS value in \data\init\init.txt.
  
 
<pre>
 
<pre>
Line 40: Line 107:
 
This script uses a system similar the commands in the designations menu to mark most of the contents of a large area for dumping. [[User:Dukederek|My talk page]] has more detailed instruction.
 
This script uses a system similar the commands in the designations menu to mark most of the contents of a large area for dumping. [[User:Dukederek|My talk page]] has more detailed instruction.
  
Essentially you need to create two text files with the following titles and content. When playing DF it is safe to have blockdumpinit running constantly as long as you dont plan on using the ctrl-d combination for something else.
+
Essentially you need to create two text files with the following titles and content. When playing DF it is safe to have blockdumpinit running constantly as long as you don't plan on using the ctrl-d combination for something else.
  
 
'''blockdumpinit.ahk'''
 
'''blockdumpinit.ahk'''
Line 282: Line 349:
  
 
SetKeyDelay, 12 ;Key delay, to keep Dwarf Fortress from being overwhelmed.
 
SetKeyDelay, 12 ;Key delay, to keep Dwarf Fortress from being overwhelmed.
:Set higher if you get weird results, or lower to get the
+
;Set higher if you get weird results, or lower to get the
:script to run faster
+
;script to run faster
 
SLEEPTIME = 12 ;same thing, only used in the repeated key press loops though
 
SLEEPTIME = 12 ;same thing, only used in the repeated key press loops though
  
Line 725: Line 792:
  
 
===Bed Assigning macro===
 
===Bed Assigning macro===
This will assign bedrooms to your dwarfs. Press F3 followed by a single digit indicating how many beds to assign. Can repeat the action, as the number of beds assigned is stored in a counter. Room size is default, but easily edited into the script. By [[User:Napsterbater|Napsterbater]].
+
This will assign bedrooms to your dwarves. Press F3 followed by a single digit indicating how many beds to assign. Can repeat the action, as the number of beds assigned is stored in a counter. Room size is default, but easily edited into the script. By [[User:Napsterbater|Napsterbater]].
  
 
<pre>
 
<pre>
Line 754: Line 821:
 
This macro can read a spreadsheet and designate rooms according to it. [http://www.bay12games.com/forum/index.php?topic=1428.0 Version 1]
 
This macro can read a spreadsheet and designate rooms according to it. [http://www.bay12games.com/forum/index.php?topic=1428.0 Version 1]
  
Version 2 of this macro apparently only works in versions up to and including 38c <sup>[[verify]]</sup>, and can be found here: [http://www.bay12games.com/forum/index.php?topic=1890.0 Version 2]
+
Version 2 of this macro apparently only works in versions up to and including 38c {{verify}}, and can be found here: [http://www.bay12games.com/forum/index.php?topic=1890.0 Version 2]
  
 
====Fedor's chambered circle====
 
====Fedor's chambered circle====
Line 858: Line 925:
  
 
====LordGrunt's room macro====
 
====LordGrunt's room macro====
Based on 1 of the fractal [[Bedroom_design| bedroom designs.]]
+
Based on 1 of the fractal [[Bedroom_design|bedroom designs.]]
  
 
[http://mkv25.net/dfma/movie-1226-fractalbedrooms Demo Movie]
 
[http://mkv25.net/dfma/movie-1226-fractalbedrooms Demo Movie]
Line 1,100: Line 1,167:
 
====Pyrofyr's room macro====
 
====Pyrofyr's room macro====
 
Based on Palin88's Apartment design based on Raynard's Fractal Design.
 
Based on Palin88's Apartment design based on Raynard's Fractal Design.
 +
 +
[[File:Pyrofor_room_macro.png]]
  
 
<pre>
 
<pre>
/************************************
+
/*
*Macro by Pyrofyr for Room Design   *
+
* Macro by Pyrofyr for Room Design -- Cleaned up by 0x517A5D
*Press Ctrl+Alt+D to start the Macro*
+
* Enter (d)esignate mode, position the cursor where you want the
************************************/
+
* middle of the design to be, then press Ctrl+Alt+D to start the Macro.
 +
*/
 +
 
 +
;Attn Pyrofor: for slash-star style comments, the ending star-slash must
 +
;be the first thing on its line.  Otherwise the comment isn't terminated.
 +
 
 +
#SingleInstance Force
 +
#IfWinActive, Dwarf Fortress
 +
SetKeyDelay 0,, Play
 +
 
 +
; Ctrl+Alt+D
 
^!d::
 
^!d::
send d
+
send d{NumPadUp 18}{NumPadLeft 18}
tehLoop(18,"{NumPadUp}")
+
;Attn Pyrofor: note how repeated keystrokes are done in AHK.
tehLoop(18,"{NumPadLeft}")
+
;no need for tehLoop().
 
directions()
 
directions()
tehLoop(18,"{NumPadRight}")
+
send {NumPadRight 18}
 
directions()
 
directions()
tehLoop(18,"{NumPadLeft}")
+
send {NumPadLeft 18}
tehLoop(18,"{NumPadDown}")
+
send {NumPadDown 18}
 
directions()
 
directions()
tehLoop(18,"{NumPadRight}")
+
send {NumPadRight 18}
 
directions()
 
directions()
 
middle()
 
middle()
 
stairs()
 
stairs()
 +
return
  
 
directions()
 
directions()
 
{
 
{
send {Enter}
+
    ;hallway box
tehLoop(18,"{NumPadRight}")
+
    send {Enter}{NumPadRight 18}{Enter}
send {Enter}
+
    send {Enter}{NumPadDown 18}{Enter}
send {Enter}
+
    send {Enter}{NumPadLeft 18}{Enter}
tehLoop(18,"{NumPadDown}")
+
    send {Enter}{NumPadUp 18}{Enter}
send {Enter}
+
    ;indentations on box
send {Enter}
+
    send {Enter}{NumPadRight 1}{NumPadDown 2}{Enter}
tehLoop(18,"{NumPadLeft}")
+
    send {NumPadDown 6}{Enter}{NumPadDown 2}{NumPadRight 1}{Enter}
send {Enter}
+
    send {NumPadLeft 1}{NumPadDown 6}{Enter}{NumPadDown 1}{Enter}
send {Enter}
+
    send {NumPadRight 6}{Enter}{NumPadRight 4}{Enter}
tehLoop(18,"{NumPadUp}")
+
    send {NumPadRight 6}{Enter}{NumPadUp 1}{Enter}
send {Enter}
+
    send {NumPadUp 6}{Enter}{NumPadUp 2}{NumPadLeft 1}{Enter}
send {Enter}
+
    send {NumPadRight 1}{NumPadUp 6}{Enter}{NumPadUp 1}{Enter}
tehLoop(1,"{NumPadRight}")
+
    send {NumPadLeft 6}{Enter}{NumPadLeft 4}{Enter}
tehLoop(2,"{NumPadDown}")
+
    ; middle hallways
send {Enter}
+
    send {NumPadRight 2}{Enter}{NumPadDown 6}{Enter}
tehLoop(6,"{NumPadDown}")
+
    send {NumPadRight 1}{Enter}{NumPadDown 4}{NumPadLeft 2}{Enter}
send {Enter}
+
    send {NumPadRight 1}{Enter}{NumPadDown 6}{Enter}
tehLoop(2,"{NumPadDown}")
+
    send {NumPadUp 8}{NumPadLeft 6}{Enter}{NumPadRight 14}{Enter}
tehLoop(1,"{NumPadRight}")
+
    ; cross apartments, horizontal segments
send {Enter}
+
    send {NumPadDown 4}{Enter}{NumPadLeft 2}{Enter}
tehLoop(1,"{NumPadLeft}")
+
    send {NumPadDown 1}{NumPadLeft 3}{Enter}{NumPadLeft 6}{Enter}
tehLoop(6,"{NumPadDown}")
+
    send {NumPadUp 1}{NumPadLeft 3}{Enter}{NumPadLeft 2}{Enter}
send {Enter}
+
    send {NumPadDown 3}{NumPadRight 2}{Enter}{NumPadRight 2}{Enter}
tehLoop(1,"{NumPadDown}")
+
    send {NumPadRight 8}{Enter}{NumPadRight 2}{Enter}
send {Enter}
+
    send {NumPadUp 5}{NumPadLeft 1}{Enter}{NumPadLeft 2}{Enter}
tehLoop(6,"{NumPadRight}")
+
    send {NumPadLeft 6}{Enter}{NumPadLeft 2}{Enter}
send {Enter}
+
    send {NumPadUp 4}{Enter}{NumPadRight 2}{Enter}
tehLoop(4,"{NumPadRight}")
+
    send {NumPadRight 6}{Enter}{NumPadRight 2}{Enter}
send {Enter}
+
    send {NumPadRight 3}{NumPadUp 2}{Enter}{NumPadLeft 2}{Enter}
tehLoop(6,"{NumPadRight}")
+
    send {NumPadUp 1}{NumPadLeft 3}{Enter}{NumPadLeft 6}{Enter}
send {Enter}
+
    send {NumPadDown 1}{NumPadLeft 3}{Enter}{NumPadLeft 2}{Enter}
tehLoop(1,"{NumPadUp}")
+
    send {NumPadUp 3}{NumPadRight 2}{Enter}{NumPadRight 2}{Enter}
send {Enter}
+
    send {NumPadRight 8}{Enter}{NumPadRight 2}{Enter}
tehLoop(6,"{NumPadUp}")
+
    ; cross apartments, vertical segments
send {Enter}
+
    send {NumPadRight 1}{NumPadDown 2}{Enter}{NumPadDown 2}{Enter}
tehLoop(2,"{NumPadUp}")
+
    send {NumPadDown 6}{Enter}{NumPadDown 2}{Enter}
tehLoop(1,"{NumPadLeft}")
+
    send {NumPadDown 3}{NumPadLeft 2}{Enter}{NumPadUp 2}{Enter}
send {Enter}
+
    send {NumPadLeft 1}{NumPadUp 3}{Enter}{NumPadUp 6}{Enter}
tehLoop(1,"{NumPadRight}")
+
    send {NumPadRight 1}{NumPadUp 3}{Enter}{NumPadUp 2}{Enter}
tehLoop(6,"{NumPadUp}")
+
    send {NumPadLeft 3}{NumPadDown 2}{Enter}{NumPadDown 2}{Enter}
send {Enter}
+
    send {NumPadDown 8}{Enter}{NumPadDown 2}{Enter}
tehLoop(1,"{NumPadUp}")
+
    send {NumPadLeft 4}{Enter}{NumPadUp 2}{Enter}
send {Enter}
+
    send {NumPadUp 8}{Enter}{NumPadUp 2}{Enter}
tehLoop(6,"{NumPadLeft}")
+
    send {NumPadUp 2}{NumPadLeft 3}{Enter}{NumPadDown 2}{Enter}
send {Enter}
+
    send {NumPadRight 1}{NumPadDown 3}{Enter}{NumPadDown 6}{Enter}
tehLoop(4,"{NumPadLeft}")
+
    send {NumPadLeft 1}{NumPadDown 3}{Enter}{NumPadDown 2}{Enter}
send {Enter}
+
    send {NumPadLeft 2}{NumPadUp 3}{Enter}{NumPadUp 2}{Enter}
tehLoop(2,"{NumPadRight}")
+
    send {NumPadUp 6}{Enter}{NumPadUp 2}{Enter}
send {Enter}
+
    send {NumPadUp 4}{NumPadLeft 2}
tehLoop(6,"{NumPadDown}")
 
send {Enter}
 
tehLoop(1,"{NumPadRight}")
 
send {Enter}
 
tehLoop(4,"{NumPadDown}")
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(1,"{NumPadRight}")
 
send {Enter}
 
tehLoop(6,"{NumPadDown}")
 
send {Enter}
 
tehLoop(8,"{NumPadUp}")
 
tehLoop(6,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(14,"{NumPadRight}")
 
send {Enter}
 
tehLoop(4,"{NumPadDown}")
 
send {Enter}
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(1,"{NumPadDown}")
 
tehLoop(3,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(6,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(1,"{NumPadUp}")
 
tehLoop(3,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(3,"{NumPadDown}")
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(8,"{NumPadRight}")
 
send {Enter}
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(5,"{NumPadUp}")
 
tehLoop(1,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(6,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(4,"{NumPadUp}")
 
send {Enter}
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(6,"{NumPadRight}")
 
send {Enter}
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(3,"{NumPadRight}")
 
tehLoop(2,"{NumPadUp}")
 
send {Enter}
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(1,"{NumPadUp}")
 
tehLoop(3,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(6,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(1,"{NumPadDown}")
 
tehLoop(3,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(3,"{NumPadUp}")
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(8,"{NumPadRight}")
 
send {Enter}
 
tehLoop(2,"{NumPadRight}")
 
send {Enter}
 
tehLoop(1,"{NumPadRight}")
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(6,"{NumPadDown}")
 
send {Enter}
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(3,"{NumPadDown}")
 
tehLoop(2,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
send {Enter}
 
tehLoop(1,"{NumPadLeft}")
 
tehLoop(3,"{NumPadUp}")
 
send {Enter}
 
tehLoop(6,"{NumPadUp}")
 
send {Enter}
 
tehLoop(1,"{NumPadRight}")
 
tehLoop(3,"{NumPadUp}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
send {Enter}
 
tehLoop(3,"{NumPadLeft}")
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(8,"{NumPadDown}")
 
send {Enter}
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(4,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
send {Enter}
 
tehLoop(8,"{NumPadUp}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
tehLoop(3,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(1,"{NumPadRight}")
 
tehLoop(3,"{NumPadDown}")
 
send {Enter}
 
tehLoop(6,"{NumPadDown}")
 
send {Enter}
 
tehLoop(1,"{NumPadLeft}")
 
tehLoop(3,"{NumPadDown}")
 
send {Enter}
 
tehLoop(2,"{NumPadDown}")
 
send {Enter}
 
tehLoop(2,"{NumPadLeft}")
 
tehLoop(3,"{NumPadUp}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
send {Enter}
 
tehLoop(6,"{NumPadUp}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
send {Enter}
 
tehLoop(4,"{NumPadUp}")
 
tehLoop(2,"{NumPadLeft}")
 
 
 
 
}
 
}
  
 
middle()
 
middle()
 
{
 
{
tehLoop(10,"{NumPadUp}")
+
    send {NumPadUp 10}{NumPadLeft 2}{Enter}{NumPadRight 4}{NumPadDown 20}{Enter}
tehLoop(2,"{NumPadLeft}")
+
    send {NumPadUp 5}{NumPadRight 1}{Enter}{NumPadUp 10}{NumPadLeft 6}{Enter}
send {Enter}
+
    send {NumPadLeft 1}{NumPadDown 1}{Enter}{NumPadDown 8}{NumPadRight 8}{Enter}
tehLoop(4,"{NumPadRight}")
+
    send {NumPadUp 2}{NumPadRight 1}{Enter}{NumPadUp 4}{NumPadLeft 10}{Enter}
tehLoop(20,"{NumPadDown}")
+
    send {NumPadDown 1}{NumPadLeft 6}{Enter}{NumPadDown 2}{NumPadRight 22}{Enter}
send {Enter}
+
    send {NumPadUp 1}{NumPadLeft 11}
tehLoop(5,"{NumPadUp}")
 
tehLoop(1,"{NumPadRight}")
 
send {Enter}
 
tehLoop(10,"{NumPadUp}")
 
tehLoop(6,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(1,"{NumPadLeft}")
 
tehLoop(1,"{NumPadDown}")
 
send {Enter}
 
tehLoop(8,"{NumPadDown}")
 
tehLoop(8,"{NumPadRight}")
 
send {Enter}
 
tehLoop(2,"{NumPadUp}")
 
tehLoop(1,"{NumPadRight}")
 
send {Enter}
 
tehLoop(4,"{NumPadUp}")
 
tehLoop(10,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(1,"{NumPadDown}")
 
tehLoop(6,"{NumPadLeft}")
 
send {Enter}
 
tehLoop(2,"{NumPadDown}")
 
tehLoop(22,"{NumPadRight}")
 
send {Enter}
 
tehLoop(1,"{NumPadUp}")
 
tehLoop(11,"{NumPadLeft}")
 
 
 
}
 
}
  
 
stairs()
 
stairs()
 
{
 
{
send i
+
    send i{NumPadUp 18}{NumPadLeft 9}{Enter 2}
tehLoop(18,"{NumPadUp}")
+
    send {NumPadRight 18}{Enter 2}
tehLoop(9,"{NumPadLeft}")
+
    send {NumPadRight 9}{NumPadDown 9}{Enter 2}
send {Enter}{Enter}
+
    send {NumPadLeft 18}{Enter 2}
tehLoop(18,"{NumPadRight}")
+
    send {NumPadLeft 18}{Enter 2}
send {Enter}{Enter}
+
    send {NumPadRight 9}{NumPadDown 9}{Enter 2}
tehLoop(9,"{NumPadRight}")
+
    send {NumPadRight 18}{Enter 2}
tehLoop(9,"{NumPadDown}")
+
    send {NumPadRight 9}{NumPadDown 9}{Enter 2}
send {Enter}{Enter}
+
    send {NumPadLeft 18}{Enter 2}
tehLoop(18,"{NumPadLeft}")
+
    send {NumPadLeft 18}{Enter 2}
send {Enter}{Enter}
+
    send {NumPadDown 9}{NumPadRight 9}{Enter 2}
tehLoop(18,"{NumPadLeft}")
+
    send {NumPadRight 18}{Enter 2}
send {Enter}{Enter}
+
    send {NumPadLeft 9}{NumPadUp 18}
tehLoop(9,"{NumPadRight}")
 
tehLoop(9,"{NumPadDown}")
 
send {Enter}{Enter}
 
tehLoop(18,"{NumPadRight}")
 
send {Enter}{Enter}
 
tehLoop(9,"{NumPadRight}")
 
tehLoop(9,"{NumPadDown}")
 
send {Enter}{Enter}
 
tehLoop(18,"{NumPadLeft}")
 
send {Enter}{Enter}
 
tehLoop(18,"{NumPadLeft}")
 
send {Enter}{Enter}
 
tehLoop(9,"{NumPadDown}")
 
tehLoop(9,"{NumPadRight}")
 
send {Enter}{Enter}
 
tehLoop(18,"{NumPadRight}")
 
send {Enter}{Enter}
 
tehLoop(27,"{NumPadLeft}")
 
tehLoop(32,"{NumPadUp}")
 
 
 
 
 
 
}
 
}
 +
</pre>
  
 
+
===Easy Exploration Mining in 2 steps===
tehLoop(tehTimes,tehDir)
+
This macro will make a 5 row, 11 column UP/DOWN stairway grid (2 empty spaces between each row/column).<br>
{
+
Starting point as indicated (row 3, column 11)<br>
loop
+
'''MUST BE IN DESIGNATION MODE WITH CURSOR AT THE ''<-- START HERE'' LOCATION'''<br>
{
 
if tehTimes <= 0
 
{
 
break
 
}
 
send %tehDir%
 
tehTimes--
 
}
 
}
 
 
 
tehOtherLoop(tehOtherDir)
 
{
 
loop 4
 
{
 
tehLoop(3,tehOtherDir)
 
send {Enter}{Enter}
 
}
 
}
 
</pre>
 
 
 
===Easy Exploration Mining in 2 steps===
 
This macro will make a 5 row, 11 column UP/DOWN stairway grid (2 empty spaces between each row/column).<br>
 
Starting point as indicated (row 3, column 11)<br>
 
'''MUST BE IN DESIGNATION MODE WITH CURSOR AT THE ''<-- START HERE'' LOCATION'''<br>
 
 
Link is <ctrl> <windowskey> `<br>
 
Link is <ctrl> <windowskey> `<br>
 
Dive is <ctrl> <alt> `<br>
 
Dive is <ctrl> <alt> `<br>
Line 1,855: Line 1,714:
  
 
====The MOUSE control====
 
====The MOUSE control====
For unrivaled mouse control in DF try [http://www.dwarffortresswiki.net/index.php/User:Digger this DF Mouse script]
+
For unrivaled mouse control in DF try [[User:Digger|this DF Mouse script]]
  
 
====Tile Counter or Scrolling Accelerator====
 
====Tile Counter or Scrolling Accelerator====
 
Lack of reference plus slow scroll speed make planning digging area frustrating,so here is the script that shows coordinate and speed scrolling up.
 
Lack of reference plus slow scroll speed make planning digging area frustrating,so here is the script that shows coordinate and speed scrolling up.
[http://www.dwarffortresswiki.net/index.php/User:Daedalusai ShowXY]
+
[[User:Daedalusai|ShowXY]]
  
 
===4-Pour Water Creation script===
 
===4-Pour Water Creation script===
Line 2,126: Line 1,985:
 
</pre>
 
</pre>
  
 +
===File pattern builder===
  
 +
This is a script to create a macro out of any building pattern you like. If you like tesselated, this script will do it. If you like blocky, this script can do that, too. Just create a text file that contains the pattern you want to use and this macro will create it like nobody's business.
  
 +
<pre>
 +
 +
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 +
; File Pattern.ahk     ;
 +
; this is an ahk script to read a text file and use   ;
 +
; the pattern contained inside as a blueprint for digging ;
 +
; press d and place the cursor   ;
 +
; in a corner of the area to be explored   ;
 +
; then use ctrl+shift+d to run   ;
 +
; to change parameters, use ctrl+shift+f   ;
 +
;   ;
 +
; NOTE:           ;
 +
; Author: Corey Amend   ;
 +
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 +
 +
filename = C:\pattern.txt
 +
loc = ul
 +
wait = 100
 +
 +
wallsymbol = 1
 +
floorsymbol = 0
 +
updownsymbol = 2
 +
downsymbol = 3
 +
upsymbol = 4
 +
rampsymbol = 5
 +
channelsymbol = 6
 +
 +
digcommand = d
 +
upcommand = u
 +
downcommand = j
 +
updowncommand = i
 +
rampcommand = r
 +
channelcommand = h
 +
 +
hdir = {Right}
 +
vdir = {Down}
 +
 +
upperleft = ul
 +
upperright = ur
 +
lowerleft = ll
 +
lowerright = lr
 +
 +
inrun = 0
 +
 +
^+f::
 +
inputbox filename, Enter Path, Enter the full path to the file that contains the pattern to use
 +
inputbox loc, Enter Cursor Location, Enter the location of the cursor within the pattern (Upper Left = ul`, Lower Right = lr...etc.)
 +
inputbox wait, Enter Delay, Enter the delay to use (default is 100)
 +
return
 +
 +
^+d::
 +
 +
IfExist,  %filename%
 +
{
 +
FileRead, contents, %filename%
 +
StringSplit Array, contents, `r, `n
 +
 +
if (loc = upperleft)
 +
{
 +
hdir = {Right}
 +
vdir = {Down}
 +
}
 +
else if (loc = upperright)
 +
{
 +
hdir = {Left}
 +
vdir = {Down}
 +
}
 +
else if (loc = lowerleft)
 +
{
 +
hdir = {Right}
 +
vdir = {Up}
 +
}
 +
else if (loc = lowerright)
 +
{
 +
hdir = {Left}
 +
vdir = {Up}
 +
}
 +
else
 +
{
 +
MsgBox, Invalid cursor location!
 +
return
 +
}
 +
 +
Loop %Array0%
 +
{
 +
if (loc = upperleft || loc = upperright)
 +
{
 +
current_line = %a_index%
 +
}
 +
else if (loc = lowerleft || loc = lowerright)
 +
{
 +
current_line := (Array0 - a_index + 1)
 +
}
 +
 +
current_value := Array%current_line%
 +
 +
len := StrLen(current_value)
 +
 +
if (hdir = "{Left}")
 +
{
 +
new_value =
 +
 +
Loop %len%
 +
{
 +
new_value := new_value . SubStr(current_value, (len - a_index) + 1, 1)
 +
}
 +
 +
current_value := new_value
 +
}
 +
 +
Loop %len%
 +
{
 +
current_char := SubStr(current_value, a_index, 1)
 +
 +
if (current_char != wallsymbol)
 +
{
 +
if (!inrun)
 +
{
 +
if (current_char = floorsymbol)
 +
{
 +
Send %digcommand%
 +
}
 +
else if (current_char = updownsymbol)
 +
{
 +
Send %updowncommand%
 +
}
 +
else if (current_char = downsymbol)
 +
{
 +
Send %downcommand%
 +
}
 +
else if (current_char = upsymbol)
 +
{
 +
Send %upcommand%
 +
}
 +
else if (current_char = rampsymbol)
 +
{
 +
Send %rampcommand%
 +
}
 +
else if (current_char = channelsymbol)
 +
{
 +
Send %channelcommand%
 +
}
 +
 +
Send {Enter}
 +
inrun = 1
 +
}
 +
 +
;;If we're at the end of a line or the next char is different, then end the run
 +
if ((a_index >= len) || (current_char != SubStr(current_value, a_index + 1, 1)))
 +
{
 +
Send {Enter}
 +
inrun = 0
 +
Sleep %wait%
 +
}
 +
}
 +
 +
if (a_index < len)
 +
{
 +
Send %hdir%
 +
}
 +
}
 +
 +
if (a_index < Array0)
 +
{
 +
Send %vdir%
 +
 +
if (hdir = "{Right}")
 +
{
 +
hdir = {Left}
 +
}
 +
else if (hdir = "{Left}")
 +
{
 +
hdir = {Right}
 +
}
 +
}
 +
}
 +
}
 +
else
 +
{
 +
MsgBox File not found
 +
}
 +
 +
</pre>
 +
 +
Sample file to show how this all works:
 +
 +
<pre>
 +
 +
111111
 +
100001
 +
100201
 +
103001
 +
100401
 +
105001
 +
100601
 +
100001
 +
111111
 +
 +
</pre>
 +
 +
This creates a room filled with up/down stairs, a ramp, and a channel.
 +
 +
And finally, here's a sample pattern based on the decentralized workshop:
 +
 +
<pre>
 +
 +
1111111111111111111111111111111111111
 +
1000000000000001000001000000000000001
 +
1000000000000001000001000000000000001
 +
1000000000000000000000000000000000001
 +
1000000000000001000001000000000000001
 +
1000000000000001000001000000000000001
 +
1000111101111111110111111111011110001
 +
1000100000001000100010001000000010001
 +
1000100000001000100010001000000010001
 +
1000100000001000100010001000000010001
 +
1000000000000010000000100000000000001
 +
1000111101111000100010001111011110001
 +
1000100000001000100010001000000010001
 +
1101100010001000100010001000100011011
 +
1000100000001000100010001000000010001
 +
1000111101111111100011111111011110001
 +
1000100000000000030400000000000010001
 +
1010000000000000030400000000000000101
 +
1000100000000000030400000000000010001
 +
1000111101111111100011111111011110001
 +
1000100000001000100010001000000010001
 +
1101100010001000100010001000100011011
 +
1000100000001000100010001000000010001
 +
1000111101111000100010001111011110001
 +
1000000000000010000000100000000000001
 +
1000100000001000100010001000000010001
 +
1000100000001000100010001000000010001
 +
1000100000001000100010001000000010001
 +
1000111101111111110111111111011110001
 +
1000000000000001000001000000000000001
 +
1000000000000001000001000000000000001
 +
1000000000000000000000000000000000001
 +
1000000000000001000001000000000000001
 +
1000000000000001000001000000000000001
 +
1111111111111111111111111111111111111
 +
 +
</pre>
 +
 +
=== jokermatt999's pump stack builder ===
 +
 +
Just a simple macro to place one mined level of a pump stack room, as illustrated in the pump stack page on this wiki. It's recommended you exit out after finishing up with it, as the macro is just assigned to p. Hit/Hold down p for multiple layers.
 +
 +
<pre>
 +
p::Send i{Enter}{Enter}{Right}d{Enter}{Right}{Right}{Down}{Down}{Enter}h{Enter}{Enter}{Up}{Left}x{Enter}{Enter}{Left}{Left}{Down}h{Enter}{Enter}{Up}{Up}{Shift Down}.{Shift Up}
 +
</pre>
 +
 +
<pre>
 +
p::
 +
Send i{Enter 2}
 +
Send d6{Enter}33{Enter}
 +
Send h{Enter 2}
 +
Send x7{Enter 2}
 +
Send h14{Enter 2}
 +
Send 88{Shift Down}.{Shift Up}
 +
return
 +
</pre>
  
 
{{Game_Interface FAQ}}
 
{{Game_Interface FAQ}}
 
[[Category:ahk scripts]]
 
[[Category:ahk scripts]]

Latest revision as of 12:24, 29 July 2021

This article is about an older version of DF.

Playing Dwarf Fortress means lots of typing. Although the game has no internal macro/keymap system (except in alpha version 40d12), using an external program can save you a great deal of time when dumping, rewalling, designating, and so forth.

  1. Go to Utilities#AutoHotKey and download AutoHotKey. Installation is simple and the program uses few system resources.
  2. Write macro scripts (file type .ahk), which may contain any number of commands. You activate scripts by double-clicking .ahk files and deactivate them by right-clicking the AutoHotKey icon on the task bar. Both of these can be done at any time - even right in the middle of a game. AutoHotKey also allows for automated activation of scripts.