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.

Editing Macros and keymaps

Jump to navigation Jump to search

Warning: You are not logged in.
Your IP address will be recorded in this page's edit history.

If you are creating a redirect to the current version's page, do not use any namespace. For example: use #REDIRECT [[Cat]], not #REDIRECT [[Main:Cat]] or #REDIRECT [[cv:Cat]]. See DF:Versions for more information.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
 
+
{{Quality|Exceptional|14:18, 4 April 2011 (UTC)}}
{{Quality|Fine}}
 
 
{{av}}
 
{{av}}
Playing ''Dwarf Fortress'' means lots of clicking and/or typing. The game has an internal macro/keymap system. Using it or any external program can save you a great deal of time when dumping, rewalling, designating, and so forth. In game settings you could toggle "Keyboard cursor enabled" to yes for macro mining designation. Unfortunately macros can only do keyboard inputs, meaning that with the v50 mouse/UI overhaul macros are far more limited than they used to be. Allegedly there are plans to reintroduce more keyboard controls, but that is not yet implemented.
+
Playing ''Dwarf Fortress'' means lots of typing. The game has an internal macro/keymap system. Using it or any external program can save you a great deal of time when dumping, rewalling, designating, and so forth.
 
 
'''Remember that many of the features and techniques listed on this page have yet to be tested in v50 versions.'''
 
  
 
== DF macros ==
 
== DF macros ==
 
=== Creating macros ===
 
=== Creating macros ===
The [[controls]] for creating macros within DF are as follows:
+
The controls for creating macros within DF are as follows:
  
*{{k|Ctrl}}+{{k|r}} = record (the REC will be shown at top left of screen and {{k|Ctrl}}+{{k|r}} again to finish recording)  
+
*{{k|Ctrl}}+{{k|r}} = record (and finish recording)
*{{k|Ctrl}}+{{k|s}} = save (name the macro then {{k|Enter}})
+
*{{k|Ctrl}}+{{k|s}} = save
*{{k|Ctrl}}+{{k|l}} = load  
+
*{{k|Ctrl}}+{{k|l}} = load
*{{k|Ctrl}}+{{k|u}}+number = set to repeat [number] of times (maximum of 99) - Note that this seems to be broken as of v50.05
+
*{{k|Ctrl}}+{{k|u}}+number = set to repeat [number] of times (maximum of 99)
*{{k|Ctrl}}+{{k|p}} = play (the PLAY will be shown at top left of screen, repeat when hold, repeating macro will stop after the mouse cursor leaves the game screen)
+
*{{k|Ctrl}}+{{k|p}} = play
  
To create a macro, press {{k|Ctrl}}+{{k|r}} to begin recording your actions.  When you have recorded all the actions that you want, stop recording by hitting {{k|Ctrl}}+{{k|r}} again and save ({{k|Ctrl}}+{{k|s}}) the macro.  The macro is then added to your macro list.  To load a macro from the list just press {{k|Ctrl}}+{{k|l}}. If you just recorded the macro, it is loaded even without saving. You can then play the macro by pressing {{k|Ctrl}}+{{k|p}} whenever you want.  You can also set a macro to repeat by pressing {{k|Ctrl}}+{{k|u}}, typing a two digit number, and then pressing {{k|Ctrl}}+{{k|p}} to begin the playback session.  Moving your mouse from the playing window, or otherwise losing focus on Dwarf Fortress, is an annoying way <s>a good way</s> to interrupt a macro session from continuing (also the only known method).
+
To create a macro, press {{k|Ctrl}}+{{k|r}} to begin recording your actions.  When you have recorded all the actions that you want, stop recording by hitting {{k|Ctrl}}+{{k|r}} again and save ({{k|Ctrl}}+{{k|s}}) the macro.  The macro is then added to your macro list.  To load a macro from the list just press {{k|Ctrl}}+{{k|l}}. If you just recorded the macro, it is loaded even without saving. You can then play the macro by pressing {{k|Ctrl}}+{{k|p}} whenever you want.  You can also set a macro to repeat by pressing {{k|Ctrl}}+{{k|u}}, typing a two digit number, and then pressing {{k|Ctrl}}+{{k|p}} to begin the playback session.  Moving your mouse from the playing window, or otherwise losing focus on Dwarf Fortress, is <s>an annoying way</s> a good way to interrupt a macro session from continuing (also the only known method).
  
The macros are stored in the <code>[[Game folder|<Dwarf Fortress>]]/prefs/macros/</code> folder. The macros are saved in .mak format. The first line of the macro file must match the filename, or the file will not be recognized as a valid macro. Even a recorded file for a simple macro - for example to create a 3 tiles wide ramp - may already consist of up to 50 commands listed. This is because every possible [[Key_bindings|binding of the key pressed]] is included in the macro and put in a block (and {{k|r}} for ramp has many by default).
+
There is a directory data/init/macros for them. The macros are saved in .mak format. The first line of the macro file must match the filename, or the file will not be recognized as a valid macro. Even a recorded file for a simple macro - for example to create a 3 tiles wide ramp - may already consist of up to 50 commands listed. This is because every possible [[Key_bindings|binding of the key pressed]] is included in the macro and put in a block (and {{k|r}} for ramp has many by default).
 
<pre>
 
<pre>
 
pressing_enter_recorded
 
pressing_enter_recorded
Line 57: Line 54:
 
</pre>
 
</pre>
 
This selfmade example will designate a 3 tiles wide ramp one z-level below and place the cursor to make the next execution of the macro continue the way down. The first line has to be the name of the file. You can see that there are grouping tags for every single keypress. These are important for a working macro.<br />
 
This selfmade example will designate a 3 tiles wide ramp one z-level below and place the cursor to make the next execution of the macro continue the way down. The first line has to be the name of the file. You can see that there are grouping tags for every single keypress. These are important for a working macro.<br />
It is unknown if there is the possibility of creating loops/iterations, other programming features or comments.<br />
+
It is unknown if there is the possibility of creationg loops/iterations, other programming features or comments.<br />
  
 
Removing macros in-game can be done by pressing {{k|Esc}} and then selecting Keybindings > Macros. Press {{k|Backspace}} on the macros you want to delete, then press {{k|Esc}} and select "Save and Exit". This will also delete the corresponding macro file permanently. Otherwise, you can delete the corresponding .mak file from the init/macros/ folder, although that will only take effect the next time DF is run.
 
Removing macros in-game can be done by pressing {{k|Esc}} and then selecting Keybindings > Macros. Press {{k|Backspace}} on the macros you want to delete, then press {{k|Esc}} and select "Save and Exit". This will also delete the corresponding macro file permanently. Otherwise, you can delete the corresponding .mak file from the init/macros/ folder, although that will only take effect the next time DF is run.
Line 227: Line 224:
 
Bedrooms, especially larger ones or large blocks of identical ones, involve a lot of designations and build orders. These macros are designed to streamline the process. For all of these mass-building macros you may wish to temporarily forbid any of your artifact or masterwork furniture, to avoid giving overly-valuable items to your dwarf peasantry.
 
Bedrooms, especially larger ones or large blocks of identical ones, involve a lot of designations and build orders. These macros are designed to streamline the process. For all of these mass-building macros you may wish to temporarily forbid any of your artifact or masterwork furniture, to avoid giving overly-valuable items to your dwarf peasantry.
  
==== Placing Beds and Furnitures ====
+
==== Placing Beds ====
 +
 
 +
So you've recorded a macro to dig out a series of bedrooms, and now you have to fill them. Bring up the {{k|b}}uild menu, select {{k|b}}ed, and go the first position you want to place a bed in.
 +
 
 +
Start a new macro ({{k|Ctrl}}+{{k|r}}) and place the bed (selecting the first bed from the list), then move to the next bedroom in sequence. Repeat this until you reach the end of the row. If you are placing beds into multiple long rows of bedrooms, move the cursor to the first bed in the next row to make things faster. Turn off macro recording ({{k|Ctrl}}+{{k|r}}), but don't exit the build menu. You can then save your macro if you wish, though it's not necessary. Play the macro ({{k|Ctrl}}+{{k|p}}), and you have just laid out another row. Repeat until you have enough bedrooms or you run out of beds.
 +
 
 +
==== Placing Coffers ====
 +
 
 +
Placing coffers (but ''not'' bags) requires an extra step. Pause the game (you ''did'' remember to pause before playing macros, didn't you?) and go to the Stocks menu. Forbid all bags, regardless of what's inside them or what they're being used for (this is temporary). Exit to main screen and repeat the steps above, this time placing containers in your rooms. You will end up placing only chests / coffers / boxes, ignoring any bags. Repeat and play back for the rest of your bedrooms, then un-forbid your bags before un-pausing the game.
  
Before placing any beds or furnitures it has some problems as the keyboard cursor will back to the middle tile of the screen the every time designate the construction.
+
==== Resizing Rooms ====
  
So you've recorded a macro to dig out a series of bedrooms, and now you have to fill them. Bring up the {{k|b}}uild menu, select {{k|f}} urniture {{k|b}}ed, Select "use closest material" and "keep building after placement", and go the first position you want to place a bed in.
+
If the bedroom is finished (at least all the beds are hauled to place), you may want to create a new macro to designate each room as a bedroom. {{k|q}}uery the building and select the first bed. Start a new macro and press {{k|r}} to designate it as a bedroom, then press + a few times to fill the available space. If you are fine with the size of the bedroom you can press enter, move on to the next bed, and repeat this for the whole row. If you want bedrooms that fill all the room and not all your bedrooms are the same size, you may have to press + a bit more or less for the larger cases. Repeat this for the rest of the rows as above.
  
Start a new macro ({{k|Ctrl}}+{{k|r}}) and place the bed (selecting the first bed from the list), then move to the next bedroom in sequence. Repeat this until you reach the end of the row. If you are placing beds into multiple long rows of bedrooms, move the cursor to the first bed in the next row to make things faster. Use {{k|w}}/{{k|a}}/{{k|s}}/{{k|d}} to make the macro loop froward it will move 11 tiles away from start from the macro you record. Turn off macro recording ({{k|Ctrl}}+{{k|r}}), but don't exit the build menu.
+
=== Mass Selector ===
You can then save your macro if you wish, though it's not necessary.
 
  
Play the macro ({{k|Ctrl}}+{{k|p}}), and you have just laid out another row. Repeat until you have enough bedrooms or you run out of beds.
+
With this macro you can select a lot of things at once. Extremely helpful if you want to sell a lot of junk to the caravans. Record {{k|enter}}, then {{k|down}} about 10-25 times in a row. (For some menus you may wish to use {{k|enter}}, then {{k|+}}) When the caravan arrives, your dwarves haul all the bins to your Trade Depot for sale as normal. At the trade menu, load the macro and play it as many times as you like. The macro will select all the items in your "for sale" list, saving the bins you carried them in for later use. Be sure to at least browse through the final list once you're done to avoid selling items you didn't wish to sell, i.e. items that were in the same bin as your trade goods that you wish to keep, or non-wood items if you're trading with the Elves.
  
 
=== Mass Trap Builder ===
 
=== Mass Trap Builder ===

Please note that all contributions to Dwarf Fortress Wiki are considered to be released under the GFDL & MIT (see Dwarf Fortress Wiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

To protect the wiki against automated edit spam, we kindly ask you to solve the following CAPTCHA:

Cancel Editing help (opens in new window)

This page is a member of 1 hidden category: