- 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.
Difference between revisions of "40d:Macros and keymaps"
m (→Dumping) |
|||
Line 24: | Line 24: | ||
return | return | ||
} | } | ||
+ | </pre> | ||
+ | |||
+ | |||
+ | A dumping script by [[User:Dukederek|Dukederek]]: | ||
+ | |||
+ | This script uses a system similar the commands in the designations menu to mark the contents of a large area for dumping. [[User:Dukederek|My talk page]] has instruction on how to use this if it is not evident from the code below | ||
+ | |||
+ | <pre> | ||
+ | ^return:: | ||
+ | x = 0 | ||
+ | y = 0 | ||
+ | IfWinActive Dwarf Fortress | ||
+ | { | ||
+ | Loop | ||
+ | { | ||
+ | Input, keypress, B, {esc} , w,a,s,d,k,q | ||
+ | if keypress = w | ||
+ | { | ||
+ | y := --y | ||
+ | Send {up} | ||
+ | continue | ||
+ | } | ||
+ | else if keypress = s | ||
+ | { | ||
+ | y := ++y | ||
+ | Send {down} | ||
+ | continue | ||
+ | } | ||
+ | else if keypress = a | ||
+ | { | ||
+ | x := --x | ||
+ | Send {left} | ||
+ | continue | ||
+ | } | ||
+ | else if keypress = d | ||
+ | { | ||
+ | x := ++x | ||
+ | Send {right} | ||
+ | continue | ||
+ | } | ||
+ | else if keypress = k | ||
+ | { | ||
+ | break | ||
+ | } | ||
+ | else if keypress = q | ||
+ | { | ||
+ | Return | ||
+ | } | ||
+ | } | ||
+ | SetKeyDelay 1 | ||
+ | Send {left %x%} | ||
+ | Send {up %y%} | ||
+ | x := x + 1 | ||
+ | y := y + 1 | ||
+ | Loop %y% | ||
+ | { | ||
+ | Loop %x% | ||
+ | { | ||
+ | Send d | ||
+ | Send {NumpadAdd} | ||
+ | Send d | ||
+ | Send {right} | ||
+ | } | ||
+ | Send {left %x%} | ||
+ | Send {down} | ||
+ | } | ||
+ | Loop %y% | ||
+ | { | ||
+ | Send {up} | ||
+ | } | ||
+ | } | ||
+ | else | ||
+ | return | ||
</pre> | </pre> | ||
Revision as of 20:39, 21 January 2008
Playing Dwarf Fortress means lots of typing. Although the game (as of version v0.27.169.33) 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.
- Go to Utilities#AutoHotKey and download AutoHotKey. Installation is simple and the program uses few system resources.
- 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.
AutoHotKey Examples
Dumping
Taken from an old version of 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.
del:: IfWinActive Dwarf Fortress { send d{down} return } else { send {del} return }
A dumping script by Dukederek:
This script uses a system similar the commands in the designations menu to mark the contents of a large area for dumping. My talk page has instruction on how to use this if it is not evident from the code below
^return:: x = 0 y = 0 IfWinActive Dwarf Fortress { Loop { Input, keypress, B, {esc} , w,a,s,d,k,q if keypress = w { y := --y Send {up} continue } else if keypress = s { y := ++y Send {down} continue } else if keypress = a { x := --x Send {left} continue } else if keypress = d { x := ++x Send {right} continue } else if keypress = k { break } else if keypress = q { Return } } SetKeyDelay 1 Send {left %x%} Send {up %y%} x := x + 1 y := y + 1 Loop %y% { Loop %x% { Send d Send {NumpadAdd} Send d Send {right} } Send {left %x%} Send {down} } Loop %y% { Send {up} } } else return
Rewalling
Taken from Valdemar's user page.
This is a macro to aid with rewalling. To use, copy-paste the script into a new .ahk file and run the script with AutoHotkey. Then, in Dwarf Fortress, press b-C-w, move the cursor to where you want to start the wall, and hold Ctrl-Shift-Arrowkey, using the direction you want to rewall in. To build floors, press b-C-f instead, and use Ctrl-Alt-Arrowkey. To stop, just release the keys.
The script will use the first material in the list. I suggest you create a stockpile near the construction site that only accepts the item you wish to build with and temporarily forbid any nearby materials you don't want to build with.
$^+Left:: ProcessEvent("Left","w") $^+Right:: ProcessEvent("Right","w") $^+Up:: ProcessEvent("Up","w") $^+Down:: ProcessEvent("Down","w") $^!Left:: ProcessEvent("Left","f") $^!Right:: ProcessEvent("Right","f") $^!Up:: ProcessEvent("Up","f") $^!Down:: ProcessEvent("Down","f") ProcessEvent(direction, type) { Send {Enter} Sleep 100 Send {Enter} Sleep 100 Send %type% Sleep 100 Send {%direction%} Loop { if not GetKeyState(direction, "P") break Send {Enter} Sleep 100 Send {Enter} Sleep 100 Send %type% Sleep 100 Send {%direction%} } }
Grid-by-grid designation
For easier diagonal and fancy mining. Assumes that DF is active. "^!" means ctrl-alt-direction.
^!NumpadEnd:: send {Enter}{Enter}{NumpadEnd} return ^!NumpadDown:: send {Enter}{Enter}{NumpadDown} return ^!NumpadPgDn:: send {Enter}{Enter}{NumpadPgDn} return ^!NumpadLeft:: send {Enter}{Enter}{NumpadLeft} return ^!NumpadRight:: send {Enter}{Enter}{NumpadRight} return ^!NumpadHome:: send {Enter}{Enter}{NumpadHome} return ^!NumpadUp:: send {Enter}{Enter}{NumpadUp} return ^!NumpadPgUp:: send {Enter}{Enter}{NumpadPgUp} return
Room-designation macros
Valdemar's Designator Macro
This macro can read a spreadsheet and designate rooms according to it. Forum Thread/Download
Fedor's chambered circle
A circular room with eight equal-sized chambers, suitable for everything from housing to workshops to a mausoleum.
See this macro in action
Macro text
Valdemar's bedroom complex
A large fractal bedroom/dining complex, with 56 bedrooms and room for 24 tables.
You can press Alt-B to create a bedroom block, or Alt-C to create a full complex with 4 bedroom blocks and a dining block in the center.
Note - the macro is much faster than the demo movie shows, it is done in under a minute.