Merge remote-tracking branch 'upstream/develop' into buildingplan_refactor

develop
Myk Taylor 2020-10-11 12:11:20 -07:00
commit bccf8a64c0
32 changed files with 1814 additions and 812 deletions

@ -4,7 +4,19 @@ on: [push, pull_request]
jobs: jobs:
build: build:
runs-on: ubuntu-18.04 runs-on: ${{ matrix.os }}
name: build (Linux, GCC ${{ matrix.gcc }})
strategy:
fail-fast: false
matrix:
os:
- ubuntu-18.04
gcc:
- 4.8
- 7
include:
- os: ubuntu-20.04
gcc: 10
steps: steps:
- name: Set up Python 3 - name: Set up Python 3
uses: actions/setup-python@v2 uses: actions/setup-python@v2
@ -14,6 +26,7 @@ jobs:
run: | run: |
sudo apt-get update sudo apt-get update
sudo apt-get install \ sudo apt-get install \
libgtk2.0-0 \
libsdl-image1.2-dev \ libsdl-image1.2-dev \
libsdl-ttf2.0-dev \ libsdl-ttf2.0-dev \
libsdl1.2-dev \ libsdl1.2-dev \
@ -23,6 +36,10 @@ jobs:
ninja-build \ ninja-build \
zlib1g-dev zlib1g-dev
pip install sphinx pip install sphinx
- name: Install GCC
if: ${{ matrix.gcc < 7 || matrix.gcc > 9 }}
run: |
sudo apt-get install gcc-${{ matrix.gcc }} g++-${{ matrix.gcc }}
- name: Clone DFHack - name: Clone DFHack
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
@ -32,9 +49,9 @@ jobs:
id: env_setup id: env_setup
run: | run: |
DF_VERSION="$(sh travis/get-df-version.sh)" DF_VERSION="$(sh travis/get-df-version.sh)"
echo "::set-env name=DF_VERSION::${DF_VERSION}"
echo "::set-output name=df_version::${DF_VERSION}" echo "::set-output name=df_version::${DF_VERSION}"
echo "::set-env name=DF_FOLDER::${HOME}/DF/${DF_VERSION}/df_linux" echo "DF_VERSION=${DF_VERSION}" >> $GITHUB_ENV
echo "DF_FOLDER=${HOME}/DF/${DF_VERSION}/df_linux" >> $GITHUB_ENV
- name: Fetch DF cache - name: Fetch DF cache
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
@ -43,15 +60,10 @@ jobs:
- name: Download DF - name: Download DF
run: | run: |
sh travis/download-df.sh sh travis/download-df.sh
- name: Build docs
run: |
sphinx-build -qW -j3 . docs/html
- name: Upload docs
uses: actions/upload-artifact@v1
with:
name: docs
path: docs/html
- name: Build DFHack - name: Build DFHack
env:
CC: gcc-${{ matrix.gcc }}
CXX: g++-${{ matrix.gcc }}
run: | run: |
cmake \ cmake \
-S . \ -S . \
@ -77,12 +89,35 @@ jobs:
name: test-artifacts name: test-artifacts
path: artifacts path: artifacts
- name: Clean up DF folder - name: Clean up DF folder
# to prevent DFHack-generated files from ending up in the cache # prevent DFHack-generated files from ending up in the cache
# (download-df.sh also removes them, this is just to save cache space) # (download-df.sh also removes them, this is just to save cache space)
if: success() || failure() if: success() || failure()
run: | run: |
rm -rf "$DF_FOLDER" rm -rf "$DF_FOLDER"
docs:
runs-on: ubuntu-18.04
steps:
- name: Set up Python 3
uses: actions/setup-python@v2
with:
python-version: 3
- name: Install dependencies
run: |
pip install sphinx
- name: Clone DFHack
uses: actions/checkout@v1
with:
submodules: true
- name: Build docs
run: |
sphinx-build -W --keep-going -j3 . docs/html
- name: Upload docs
uses: actions/upload-artifact@v1
with:
name: docs
path: docs/html
lint: lint:
runs-on: ubuntu-18.04 runs-on: ubuntu-18.04
steps: steps:

@ -185,7 +185,7 @@ endif()
# set up versioning. # set up versioning.
set(DF_VERSION "0.47.04") set(DF_VERSION "0.47.04")
set(DFHACK_RELEASE "r2") set(DFHACK_RELEASE "r3")
set(DFHACK_PRERELEASE FALSE) set(DFHACK_PRERELEASE FALSE)
set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}") set(DFHACK_VERSION "${DF_VERSION}-${DFHACK_RELEASE}")
@ -442,6 +442,7 @@ if(BUILD_DOCS)
file(GLOB SPHINX_DEPS file(GLOB SPHINX_DEPS
"${CMAKE_CURRENT_SOURCE_DIR}/docs/*.rst" "${CMAKE_CURRENT_SOURCE_DIR}/docs/*.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/docs/guides/*.rst"
"${CMAKE_CURRENT_SOURCE_DIR}/docs/changelog.txt" "${CMAKE_CURRENT_SOURCE_DIR}/docs/changelog.txt"
"${CMAKE_CURRENT_SOURCE_DIR}/docs/gen_changelog.py" "${CMAKE_CURRENT_SOURCE_DIR}/docs/gen_changelog.py"
"${CMAKE_CURRENT_SOURCE_DIR}/docs/images/*.png" "${CMAKE_CURRENT_SOURCE_DIR}/docs/images/*.png"

@ -195,18 +195,21 @@ needs_sphinx = '1.8'
extensions = [ extensions = [
'sphinx.ext.extlinks', 'sphinx.ext.extlinks',
'dfhack.changelog', 'dfhack.changelog',
'dfhack.lexer',
] ]
# This config value must be a dictionary of external sites, mapping unique # This config value must be a dictionary of external sites, mapping unique
# short alias names to a base URL and a prefix. # short alias names to a base URL and a prefix.
# See http://sphinx-doc.org/ext/extlinks.html # See http://sphinx-doc.org/ext/extlinks.html
extlinks = { extlinks = {
'wiki': ('http://dwarffortresswiki.org/%s', ''), 'wiki': ('https://dwarffortresswiki.org/%s', ''),
'forums': ('http://www.bay12forums.com/smf/index.php?topic=%s', 'forums': ('http://www.bay12forums.com/smf/index.php?topic=%s',
'Bay12 forums thread '), 'Bay12 forums thread '),
'dffd': ('http://dffd.bay12games.com/file.php?id=%s', 'DFFD file '), 'dffd': ('https://dffd.bay12games.com/file.php?id=%s', 'DFFD file '),
'bug': ('http://www.bay12games.com/dwarves/mantisbt/view.php?id=%s', 'bug': ('https://www.bay12games.com/dwarves/mantisbt/view.php?id=%s',
'Bug '), 'Bug '),
'source': ('https://github.com/DFHack/dfhack/tree/develop/%s', ''),
'source:scripts': ('https://github.com/DFHack/scripts/tree/master/%s', ''),
'issue': ('https://github.com/DFHack/dfhack/issues/%s', 'Issue '), 'issue': ('https://github.com/DFHack/dfhack/issues/%s', 'Issue '),
'commit': ('https://github.com/DFHack/dfhack/commit/%s', 'Commit '), 'commit': ('https://github.com/DFHack/dfhack/commit/%s', 'Commit '),
} }
@ -280,6 +283,9 @@ default_role = 'ref'
# The name of the Pygments (syntax highlighting) style to use. # The name of the Pygments (syntax highlighting) style to use.
pygments_style = 'sphinx' pygments_style = 'sphinx'
# The default language to highlight source code in.
highlight_language = 'dfhack'
# If true, `todo` and `todoList` produce output, else they produce nothing. # If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = False todo_include_todos = False

@ -1,756 +1,4 @@
This folder contains blueprints used by the `quickfort` script. For more information, see:
[//]: # (The online version of this manual, which may be easier to read, is) * [Quickfort command reference](https://docs.dfhack.org/en/stable/docs/_auto/base.html#quickfort)
[//]: # (at https://github.com/DFHack/dfhack/tree/develop/data/blueprints) * [Quickfort user guide](https://docs.dfhack.org/en/stable/docs/guides/quickfort-user-guide.html)
[//]: # (Note to editors: don't word wrap -- it breaks the formatting on GitHub)
DFHack Quickfort User Manual
============================
DFHack Quickfort is a DFHack script that helps you build fortresses from "blueprint" .csv and .xlsx files. Many applications exist to edit these files, such as MS Excel and [Google Sheets](https://sheets.new). You can also build your plan "for real" in Dwarf Fortress, and then export your map using DFHack's [blueprint](https://docs.dfhack.org/en/stable/docs/Plugins.html#blueprint) plugin. Most layout and building-oriented DF commands are supported through the use of multiple files or spreadsheets, each describing a different phase of DF construction: designation, building, placing stockpiles/zones, and setting configuration.
The original idea and 1.0 codebase came from [Valdemar's](https://dwarffortresswiki.org/index.php/User:Valdemar) auto-designation macro. Joel Thornton (joelpt) reimplemented the core logic in Python and extended its functionality with [Quickfort 2.0](https://github.com/joelpt/quickfort). This DFHack-native implementation, called "DFHack Quickfort" or just "quickfort", builds upon Quickfort 2.0's formats and features. DFHack Quickfort is written in Lua and interacts with Dwarf Fortress memory structures directly, allowing for instantaneous blueprint application, error checking and recovery, and many other advanced features.
This document focuses on DFHack Quickfort's capabilities and teaches players how to understand and build blueprint files. Some of the text was originally written by Joel Thornton, reused here with his permission.
For those just looking to apply blueprints, check out the [quickfort command syntax](https://docs.dfhack.org/en/stable/docs/_auto/base.html#quickfort) in the DFHack Scripts documentation. There are also many ready-to-use blueprints available in the `blueprints/library` subfolder in your DFHack installation. Browse them on your computer or [online](https://github.com/DFHack/dfhack/tree/develop/data/blueprints/library), or run `quickfort list -l` at the `DFHack#` prompt to list them, and then `quickfort run` to apply them to your fort!
See the [Links section](#links) for more information and online resources.
Table of Contents
-----------------
* [Features](#features)
* [Editing Blueprints](#editing-blueprints)
* [Area expansion syntax](#area-expansion-syntax)
* [Automatic area expansion](#automatic-area-expansion)
* [Multilevel blueprints](#multilevel-blueprints)
* [Marker mode](#marker-mode)
* [Dig priorities](#dig-priorities)
* [Stockpiles and zones](#stockpiles-and-zones)
* [Minecart tracks](#minecart-tracks)
* [Modeline markers](modeline-markers)
* [Packaging a set of blueprints](#packaging-a-set-of-blueprints)
* [Meta blueprints](#meta-blueprints)
* [Buildingplan integration](#buildingplan-integration)
* [Generating manager orders](#generating-manager-orders)
* [Tips and tricks](#tips-and-tricks)
* [Caveats and limitations](#caveats-and-limitations)
* [Links](#links)
Features
--------
* General
* Manages blueprints to handle all phases of DF construction
* Supports .csv and multi-worksheet .xlsx blueprint files
* Near-instant application, even for very large and complex blueprints
* Blueprints can span multiple z-levels
* Supports multiple blueprints per .csv file/spreadsheet sheet
* "meta" blueprints that automate the application of sequences of blueprints
* Undo functionality for dig, build, place, and zone blueprints
* Automatic cropping of blueprints so you don't get errors if the blueprint extends off the map
* Can generate manager orders for everything required by a build blueprint
* Library of ready-to-use blueprints included
* Verbose output mode for debugging
* Dig mode
* Supports all types of designations, including dumping/forbidding items and setting traffic settings
* Supports setting dig priorities
* Supports applying dig blueprints in marker mode
* Handles carving arbitrarily complex minecart tracks, including tracks that cross other tracks
* Build mode
* DFHack buildingplan integration
* Designate complete constructions at once, without having to wait for each tile to become supported before you can build it
* Automatic expansion of building footprints to their minimum dimensions, so only the center tile of a multi-tile building needs to be recorded in the blueprint
* Tile occupancy and validity checking so, for example, buildings that cannot be placed on a certain tile will simply be skipped instead of the blueprint failing to apply. Blueprints that are only partially applied for any reason (for example, you need to dig out some more tiles) can be safely reapplied to build the remaining buildings.
* Relaxed rules for farm plot and road placement: you can still place the building even if an invalid tile (e.g. stone tiles for farm plots) splits the designated area into two parts
* Intelligent boundary detection for adjacent buildings of the same type (e.g. a 6x6 block of `wj` cells will be correctly split into 4 jeweler's workshops)
* Place and zone modes
* Define stockpiles and zones in any continguous shape, not just rectangular blocks
* Configurable maximums for bins, barrels and wheelbarrows assigned to created stockpiles
* Automatic splitting of stockpiles and zones that exceed maximum dimension limits
* Query mode
* Send arbitrary keystroke sequences to the UI -- *anything* you can do through the UI is supported
* Supports aliases to automate frequent keystroke combos
* Includes a library of pre-made and tested aliases to automate most common tasks, such as configuring stockpiles for important item types or creating named hauling routes for quantum stockpiles.
* Supports including aliases in other aliases, and repeating key sequences a specified number of times
* Skips sending key sequences when the cursor is over a tile that does not have a stockpile or building, so missing buildings won't desynchronize your blueprint
* Instant halting of query blueprint application when keystroke errors are detected, such as when a key sequence leaves us stuck in a submenu, to make blueprint misconfigurations easier to debug
Editing Blueprints
------------------
We recommend using a spreadsheet editor such as Excel, [Google Sheets](https://sheets.new), or [LibreOffice](https://www.libreoffice.org) to edit blueprint files, but any text editor will do.
The format of Quickfort-compatible blueprint files is straightforward. The first line (or upper-left cell) of the spreadsheet should look like this:
#dig This is a decription.
The keyword "dig" tells Quickfort we are going to be using the Designations menu in DF. The following "mode" keywords are understood:
dig Designations menu (d)
build Build menu (b)
place Place stockpiles menu (p)
zone Activity zones menu (i)
query Set building tasks/prefs menu (q)
There are also "meta" blueprints, but we'll talk about those [later](#meta-blueprints).
Optionally following this keyword and a space, you may enter a comment. This comment will appear in the output of `quickfort list` when run from the `DFHack#` prompt. You can use this space for explanations, attribution, etc.
Below this line begin entering the keys you want sent in each cell. For example, we could dig out a 4x4 room like so (spaces are used as column separators here for clarity, but a real .csv file would have commas):
#dig
d d d d #
d d d d #
d d d d #
d d d d #
# # # # #
Note the # symbols at the right end of each row and below the last row. These are completely optional, but can be helpful to make the row and column positions clear.
Once the dwarves have that dug out, let's build a walled-in bedroom within our dug-out area:
#build
Cw Cw Cw Cw #
Cw b h Cw #
Cw Cw #
Cw Cw Cw #
# # # # #
Note my generosity - in addition to the bed (b) I've built a chest (h) here for the dwarf as well. You must use the full series of keys needed to build something in each cell, e.g. 'Cw' enters DF's constructions submenu (C) and selects walls (w).
I'd also like to place a booze stockpile in the 2 unoccupied tiles in the room.
#place Place a food stockpile
` ` ` ` #
` ` ` ` #
` f(2x1)#
` ` ` ` #
# # # # #
This illustration may be a little hard to understand. The f(2x1) is in column 2, row 3. All the other cells are empty. QF considers both "`" (backtick -- the character under the tilde) and "~" (tilde) characters within cells to be empty cells; this can help with multilayer or fortress-wide blueprint layouts as 'chalk lines'.
With f(2x1), we've asked QF to place a food stockpile 2 units wide by 1 high unit. Note that the f(2x1) syntax isn't actually necessary here; we could have just used:
#place Place a food stockpile
` ` ` ` #
` ` ` ` #
` f f ` #
` ` ` ` #
# # # # #
QF is smart enough to recognize this as a 2x1 food stockpile, and creates it as such rather than as two 1x1 food stockpiles. Quickfort recognizes any connected region of identical designations as a single stockpile. The tiles can be connected orthogonally or diagonally, just as long as they are touching somehow.
Lastly, let's turn the bed into a bedroom and set the food stockpile to hold only booze.
#query
` ` ` ` #
` r& ` #
` booze #
` ` ` ` #
# # # # #
In column 2, row 2 we have "r&". This sends the "r" key to DF when the cursor is over the bed, causing us to 'make room' and "&", which is a special symbol that expands to "{Enter}", to indicate that we're done.
In column 2, row 3 we have "booze". This is one of many alias keywords defined in the included [baseline aliases file](https://github.com/DFHack/dfhack/tree/develop/data/quickfort/aliases-common.txt). This particular alias sets a food stockpile to carry booze only. It sends the keys needed to navigate DF's stockpile settings menu, and then sends an Escape character ("^" or "{ESC}") to exit back to the map. It is important to exit out of any menus that you enter while in query mode so that the cursor can move to the next tile when it is done configuring the current tile.
Check out the included [blueprint library](https://github.com/DFHack/dfhack/tree/develop/data/blueprints/library) to see many more examples. Read the baseline aliases file for helpful pre-packaged aliases, or create your own in [dfhack-config/quickfort/aliases.txt](https://github.com/DFHack/dfhack/tree/develop/dfhack-config/quickfort/aliases.txt) in your DFHack installation.
Area expansion syntax
---------------------
In Quickfort, the following blueprints are equivalent:
#dig a 3x3 area
d d d #
d d d #
d d d #
# # # #
#dig the same area with d(3x3) specified in row 1, col 1
d(3x3)#
` ` ` #
` ` ` #
# # # #
The second example uses Quickfort's "area expansion syntax", which takes the form:
keys(WxH)
In Quickfort the above two examples of specifying a contiguous 3x3 area produce identical output: a single 3x3 designation will be performed, rather than nine 1x1 designations as the first example might suggest.
Area expansion syntax can only specify rectangular areas. If you want to create extent-based structures (e.g. farm plots or stockpiles) in different shapes, use the first format above. For example:
#place L shaped food stockpile
f f ` ` #
f f ` ` #
f f f f #
f f f f #
# # # # #
Area expansion syntax also sets boundaries, which can be useful if you want adjacent, but separate, stockpiles of the same type:
#place Two touching but separate food stockpiles
f(4x2) #
~ ~ ~ ~ #
f(4x2) #
~ ~ ~ ~ #
# # # # #
As mentioned previously, "~" characters are ignored as comment characters and can be used for visualizing the blueprint layout. The blueprint can be equivalently written as:
#place Two touching but separate food stockpiles
f(4x2) #
~ ~ ~ ~ #
f f f f #
f f f f #
# # # # #
since the area expansion syntax of the upper stockpile prevents it from combining with the lower, freeform syntax stockpile.
Area expansion syntax can also be used for buildings which have an adjustable size, like bridges. The following blueprints are equivalent:
#build a 4x2 bridge from row 1, col 1
ga(4x2) ` #
` ` ` ` #
# # # # #
#build a 4x2 bridge from row 1, col 1
ga ga ga ga #
ga ga ga ga #
# # # # #
Automatic area expansion
------------------------
Buildings larger than 1x1, like workshops, can be represented in any of three ways. You can designate just their center tile with empty cells around it to leave room for the footprint, like this:
#build a mason workshop in row 2, col 2 that will occupy the 3x3 area
` ` ` #
` wm ` #
` ` ` #
# # # #
Or you can fill out the entire footprint like this:
#build a mason workshop
wm wm wm #
wm wm wm #
wm wm wm #
# # # #
This format may be verbose for regular workshops, but it can be very helpful for laying out structures like screw pump towers and waterwheels, whose "center point" can be non-obvious.
Finally, you can use area expansion syntax to represent the workshop:
#build a mason workshop
wm(3x3) #
` ` ` #
` ` ` #
# # # #
This style can be convenient for laying out multiple buildings of the same type. If you are building a large-scale block factory, for example, this will create 20 mason workshops all in a row:
#build line of 20 mason workshops
wm(60x3) #
Quickfort will intelligently break large areas of the same designation into appropriately-sized chunks.
Multilevel blueprints
---------------------
Multilevel blueprints are accommodated by separating Z-levels of the blueprint with `#>` (go down one z-level) or `#<` (go up one z-level) at the end of each floor.
#dig Stairs leading down to a small room below
j ` ` #
` ` ` #
` ` ` #
#> # # #
u d d #
d d d #
d d d #
# # # #
The marker must appear in the first column of the row to be recognized, just like a modeline.
Dig priorities
--------------
DF designation priorities are supported for `#dig` blueprints. The full syntax is `[letter][number][expansion]`, where if the `letter` is not specified, `d` is assumed, and if `number` is not specified, `4` is assumed (the default priority). So each of these blueprints is equivalent:
#dig dig the interior of the room at high priority
d d d d d #
d d1 d1 d1 d #
d d1 d1 d1 d #
d d1 d1 d1 d #
d d d d d #
# # # # # #
#dig dig the interior of the room at high priority
d d d d d #
d d1(3x3) d #
d ` ` ` d #
d ` ` ` d #
d d d d d #
# # # # # #
#dig dig the interior of the room at high priority
4 4 4 4 4 #
4 1 1 1 4 #
4 1 1 1 4 #
4 1 1 1 4 #
4 4 4 4 4 #
# # # # # #
Marker mode
-----------
Marker mode is useful for when you want to plan out your digging, but you don't want to dig everything just yet. In `#dig` mode, you can add a `m` before any other designation letter to indicate that the tile should be designated in marker mode. For example, to dig out the perimeter of a room, but leave the center of the room marked for digging later:
#dig
d d d d d #
d md md md d #
d md md md d #
d md md md d #
d d d d d #
# # # # # #
Then you can use "Toggle Standard/Marking" (`d-M`) to convert the center tiles to regular designations at your leisure.
To apply an entire dig blueprint in marker mode, regardless of what the blueprint itself says, you can set the global quickfort setting `force_marker_mode` to `true` before you apply the blueprint.
Note that the in-game UI setting "Standard/Marker Only" (`d-m`) does not have any effect on quickfort.
Stockpiles and zones
--------------------
It is very common to have stockpiles that accept multiple categories of items or zones that permit more than one activity. Although it is perfectly valid to declare a single-purpose stockpile or zone and then modify it with a `#query` blueprint, quickfort also supports directly declaring all the types on the `#place` and `#zone` blueprints. For example, to declare a 10x10 area that is a pasture, a fruit picking area, and a meeting area all at once, you could write:
#zone main pasture and picnic area
nmg(10x10)
And similarly, to declare a stockpile that accepts both corpses and refuse, you could write:
#place refuse heap
yr(20x10)
The order of the individual letters doesn't matter.
To toggle the `active` flag for zones, add an `a` character to the string. For example, to create a *disabled* pit zone (that you later intend to turn into a pond and carefully fill to 3-depth water):
#zone disabled future pond zone
pa(1x3)
Note that while this notation covers most use cases, tweaking low-level zone parameters, like hospital supply levels or converting between pits and ponds, must still be done manually or with a `#query` blueprint.
Minecart tracks
---------------
There are two ways to produce minecart tracks, and they are handled very differently by the game. You can carve them into hard natural floors or you can construct them out of building materials. Constructed tracks are conceptually simpler, so we'll start with them.
### Constructed tracks ###
Quickfort supports the designation of track stops and rollers through the normal mechanisms: a `#build` blueprint with `CS` and some number of `d` and `a` characters (for selecting dump direction and friction) in a cell designates a track stop and a `#build` blueprint with `Mr` and some number of `s` and `q` characters (for direction and speed) designates a roller. This can get confusing very quickly and is very difficult to read in a blueprint. Constructed track segments don't even have keys associated with them at all!
To solve this problem, Quickfort provides the following keywords for use in build blueprints:
-- Track segments --
trackN
trackS
trackE
trackW
trackNS
trackNE
trackNW
trackSE
trackSW
trackEW
trackNSE
trackNSW
trackNEW
trackSEW
trackNSEW
-- Track/ramp segments --
trackrampN
trackrampS
trackrampE
trackrampW
trackrampNS
trackrampNE
trackrampNW
trackrampSE
trackrampSW
trackrampEW
trackrampNSE
trackrampNSW
trackrampNEW
trackrampSEW
trackrampNSEW
-- Horizontal and vertical roller segments --
rollerH
rollerV
rollerNS
rollerSN
rollerEW
rollerWE
Note: append up to four 'q' characters to roller keywords to set roller
speed. E.g. a roller that propels from East to West at the slowest speed can
be specified with 'rollerEWqqqq'.
-- Track stops that (optionally) dump to the N/S/E/W --
trackstop
trackstopN
trackstopS
trackstopE
trackstopW
Note: append up to four 'a' characters to trackstop keywords to set friction
amount. E.g. a stop that applies the smallest amount of friction can be
specified with 'trackstopaaaa'.
As an example, you can create an E-W track with stops at each end that dump to their outside directions with the following blueprint:
#build Example track
trackstopW trackEW trackEW trackEW trackstopE
Note that the **only** way to build track and track/ramp segments is with the keywords. The UI method of using "+" and "-" keys to select the track type from a list does not work since DFHack Quickfort doesn't actually send keys to the UI to build buildings. The text in your spreadsheet cells is mapped directly into DFHack API calls. Only `#query` blueprints still send actual keycodes to the UI.
### Carved tracks ###
In the game, you carve a minecart track by specifying a beginning and ending tile and the game "adds" the designation to the tiles. You cannot designate single tiles. For example to carve two track segments that cross each other, you might use the cursor to designate a line of three vertical tiles like this:
` start here ` #
` ` ` #
` end here ` #
# # # #
Then to carve the cross, you'd do a horizonal segment:
` ` ` #
start here ` end here #
` ` ` #
# # # #
This will result in a carved track that would be equivalent to a constructed track of the form:
#build
` trackS ` #
trackE trackNSEW trackW #
` trackN ` #
# # # #
To carve this same track with a `#dig` blueprint, you'd use area expansion syntax with a height or width of 1 to indicate the segments to designate:
#dig
` T(1x3) ` #
T(3x1) ` ` #
` ` ` #
# # # #
"But wait!", I can hear you say, "How do you designate a track corner that opens to the South and East? You can't put both T(1xH) and T(Wx1) in the same cell!" This is true, but you can specify both width and height, and for tracks, QF interprets it as an upper-left corner extending to the right W tiles and down H tiles. For example, to carve a track in a closed ring, you'd write:
#dig
T(3x3) ` T(1x3) #
` ` ` #
T(3x1) ` ` #
# # # #
Which would result in a carved track simliar to a constructed track of the form:
#build
trackSE trackEW trackSW #
trackNS ` trackNS #
trackNE trackEW trackNW #
# # # #
Modeline markers
----------------
The modeline has some additional optional components that we haven't talked about yet. You can:
* give a blueprint a label by adding a `label()` marker
* set a cursor offset and/or start hint by adding a `start()` marker
* hide a blueprint from being listed with a `hidden()` marker
* register a message to be displayed after the blueprint is successfully applied
The full modeline syntax, when everything is specified, is:
#mode label(mylabel) start(X;Y;STARTCOMMENT) hidden() message(mymessage) comment
Note that all elements are optional except for the initial `#mode`. Here are a few examples of modelines with optional elements before we discuss them in more detail:
#dig start(3; 3; Center tile of a 5-tile square) Regular blueprint comment
#build label(noblebedroom) start(10;15)
#query label(configstockpiles) No explicit start() means cursor is at upper left corner
#meta label(digwholefort) start(center of stairs on surface)
#dig label(digdining) hidden() managed by the digwholefort meta blueprint
#zone label(pastures) message(remember to assign animals to the new pastures)
### Blueprint labels ###
Labels are displayed in the `quickfort list` output and are used for addressing specific blueprints when there are multiple blueprints in a single file or spreadsheet sheet (see [Packaging a set of blueprints](#packaging-a-set-of-blueprints) below). If a blueprint has no label, the label becomes the ordinal of the blueprint's position in the file or sheet. For example, the label of the first blueprint will be "1" if it is not otherwise set, the label of the second blueprint will be "2" if it is not otherwise set, etc. Labels that are explicitly defined must start with a letter to ensure the auto-generated labels don't conflict with user-defined labels.
### Start positions ###
Start positions specify a cursor offset for a particular blueprint, simplifying the task of blueprint alignment. This is very helpful for blueprints that are based on a central staircase, but it helps whenever a blueprint has an obvious "center". For example:
#build start(2;2;center of workshop) label(masonw) a mason workshop
wm wm wm #
wm wm wm #
wm wm wm #
# # # #
will build the workshop *centered* on the cursor, not down and to the right of the cursor.
The two numbers specify the column and row (or X and Y offset) where the cursor is expected to be when you apply the blueprint. Position 1;1 is the top left cell. The optional comment will show up in the `quickfort list` output and should contain information about where to position the cursor. If the start position is 1;1, you can omit the numbers and just add a comment describing where to put the cursor. This is also useful for meta blueprints that don't actually care where the cursor is, but that refer to other blueprints that have fully-specified `start()` markers. For example, a meta blueprint that refers to the `masonw` blueprint above could look like this:
#meta start(center of workshop) a mason workshop
/masonw
### Hiding blueprints ###
A blueprint with a `hidden()` marker won't appear in `quickfort list` output unless the `--hidden` flag is specified. The primary reason for hiding a blueprint (rather than, say, deleting it or moving it out of the `blueprints/` folder) is if a blueprint is intended to be run as part of a larger sequence managed by a [meta blueprint](#meta-blueprints).
### Messages ###
A blueprint with a `message()` marker will display a message after the blueprint is applied with `quickfort run`. This is useful for reminding players to take manual steps that cannot be automated, like assigning animals to a pasture or assigning minecarts to a route, or listing the next step in a series of blueprints. For long or multi-part messages, you can embed newlines:
"#meta label(surface1) message(This would be a good time to start digging the industry level.
Once the area is clear, continue with /surface2.) clear the embark site and set up pastures"
Packaging a set of blueprints
-----------------------------
A complete specification for a section of your fortress may contain 5 or more separate blueprints, one for each "phase" of construction (dig, build, place stockpiles, designate zones, query building adjustments).
To manage all the separate blueprints, it is often convenient to keep related blueprints in a single file. For .xlsx spreadsheets, you can keep each blueprint in a separate sheet. Online spreadsheet applications like [Google Sheets](https://sheets.new) make it easy to work with multiple related blueprints, and, as a bonus, they retain any formatting you've set, like column sizes and coloring.
For both .csv files and .xlsx spreadsheets you can also add as many blueprints as you want in a single file or sheet. Just add a modeline in the first column to indicate the start of a new blueprint. Instead of multiple .csv files, you can concatenate them into one single file.
For example, you can store multiple blueprints together like this:
#dig label(bed1)
d d d d #
d d d d #
d d d d #
d d d d #
# # # # #
#build label(bed2)
b f h #
#
#
n #
# # # # #
#place label(bed3)
#
f(2x2) #
#
#
# # # # #
#query label(bed4)
#
booze #
#
#
# # # # #
#query label(bed5)
r{+ 3}& #
#
#
#
# # # # #
Of course, you could still choose to keep your blueprints in single-sheet .csv files and just give related blueprints similar names:
bedroom.1.dig.csv
bedroom.2.build.csv
bedroom.3.place.csv
bedroom.4.query.csv
bedroom.5.query2.csv
But the naming and organization is completely up to you.
Meta blueprints
---------------
Meta blueprints are blueprints that script a series of other blueprints. Many blueprint packages follow this pattern:
- Apply dig blueprint to designate dig areas
- Wait for miners to dig
- **Apply build buildprint** to designate buildings
- **Apply place buildprint** to designate stockpiles
- **Apply query blueprint** to configure stockpiles
- Wait for buildings to get built
- Apply a different query blueprint to configure rooms
Those three "apply"s in the middle might as well get done in one command instead of three. A meta blueprint can encode that sequence. A meta blueprint refers to other blueprints by their label (see the [Modeline markers](modeline-markers) section above) in the same format used by the `DFHack#` quickfort command: "<sheet_name>/<label>", or just "/<label>" for blueprints in .csv files or blueprints in the same spreadsheet sheet as the #meta blueprint that references them.
A few examples might make this clearer. Say you have a .csv file with the "bed" blueprints in the previous section:
#dig label(bed1)
...
#build label(bed2)
...
#place label(bed3)
...
#query label(bed4)
...
#query label(bed5)
...
Note how I've given them all labels so we can address them safely. If I hadn't given them labels, they would receive default labels of "1", "2", "3", etc, but those labels would change if I ever add more blueprints at the top. This is not a problem if we're just running the blueprints individually from the `quickfort list` command, but meta blueprints need a label name that isn't going to change over time.
So let's add a meta blueprint to this file that will combine the middle three blueprints into one:
"#meta plan bedroom: combines build, place, and stockpile config blueprints"
/bed2
/bed3
/bed4
Now your sequence is shortened to:
- Apply dig blueprint to designate dig areas
- Wait for miners to dig
- **Apply meta buildprint** to build buildings and designate/configure stockpiles
- Wait for buildings to get built
- Apply the final query blueprint to configure the room
You can use meta blueprints to lay out your fortress at a larger scale as well. The `#<` and `#>` notation is valid in meta blueprints, so you can, for example, store the dig blueprints for all the levels of your fortress in different sheets in a spreadsheet, and then use a meta blueprint to designate your entire fortress for digging at once. For example, say you have a spreadsheet with the following layout:
Sheet name | contents
---------- | --------
dig_farming | one #dig blueprint, no label
dig_industry | one #dig blueprint, no label
dig_dining | four #dig blueprints, with labels "main", "basement", "waterway", and "cistern"
dig_guildhall | one #dig blueprint, no label
dig_suites | one #dig blueprint, no label
dig_bedrooms | one #dig blueprint, no label
We can add a sheet named "dig_all" with the following contents (we're expecting a big fort, so we're planning for a lot of bedrooms):
#meta dig the whole fortress (remember to set force_marker_mode to true)
dig_farming/1
#>
dig_industry/1
#>
#>
dig_dining/main
#>
dig_dining/basement
#>
dig_dining/waterway
#>
dig_dining/cistern
#>
dig_guildhall/1
#>
dig_suites/1
#>
dig_bedrooms/1
#>
dig_bedrooms/1
#>
dig_bedrooms/1
#>
dig_bedrooms/1
#>
dig_bedrooms/1
Note that for blueprints without an explicit label, we still need to address them by their auto-generated numerical label.
You can then hide the blueprints that you now manage with the `#meta`-mode blueprint from `quickfort list` by adding a `hidden()` marker to their modelines. That way the output of `quickfort list` won't be cluttered by blueprints that you don't need to run directly. If you ever *do* need to access the managed blueprints individually, you can still see them with `quickfort list --hidden`.
Buildingplan integration
------------------------
Buildingplan is a DFHack plugin that keeps jobs in a suspended state until the materials required for the job are available. This prevents a building designation from being canceled when a dwarf picks up the job but can't find the materials.
For all types that buildingplan supports, quickfort using buildingplan to manage construction. Buildings are still constructed immediately if you have the materials, but you now have the freedom to apply build blueprints before you manufacture all required materials, and the jobs will be fulfilled as the materials become available.
If a `#build` blueprint only refers to supported types, the buildingplan integration pairs well with the [workflow](https://docs.dfhack.org/en/stable/docs/Plugins.html#workflow) plugin, which can build items a few at a time continuously as long as they are needed. For building types that are not yet supported by buildingplan, a good pattern to follow is to first run `quickfort orders` on the `#build` blueprint to manufacture all the required items, then apply the blueprint itself.
See [buildingplan documentation](https://docs.dfhack.org/en/stable/docs/Plugins.html#buildingplan) for a list of supported types.
Generating manager orders
-------------------------
Quickfort can generate manager orders to make sure you have the proper items in stock to apply a `#build` blueprint.
Many items can be manufactured from different source materials. Orders will always choose rock when it can, then wood, then cloth, then iron. You can always remove orders that don't make sense for your fort and manually enqueue a similar order more to your liking. For example, if you want silk ropes instead of cloth ropes, make a new manager order for an appropriate quantity of silk ropes, and then remove the generated cloth rope order.
Anything that requires generic building materials (workshops, constructions, etc.) will result in an order for a rock block. One "Make rock blocks" job produces four blocks per boulder, so the number of jobs ordered will be the number of blocks you need divided by four (rounded up). You might end up with a few extra blocks, but not too many.
If you want your constructions to be in a consistent color, be sure to choose a rock type for all of your 'Make rock blocks' orders by selecting the order and hitting `d`. You might want to set the rock type for other non-block orders to something different if you fear running out of the type of rock that you want to use for blocks.
There are a few building types that will generate extra manager orders for related materials:
- Track stops will generate an order for a minecart
- Traction benches will generate orders for a table, mechanism, and rope
- Levers will generate an order for an extra two mechanisms for connecting the lever to a target
- Cage traps will generate an order for a cage
Tips and tricks
---------------
* During blueprint application, especially query blueprints, don't click the mouse on the DF window or type any keys. They can change the state of the game while the blueprint is being applied, resulting in strange errors.
* After digging out an area, you may wish to smooth and/or engrave the area before starting the build phase, as dwarves may be unable to access walls or floors that are behind/under built objects.
* If you are designating more than one level for digging at a time, you can make your miners more efficient by using marker mode on all levels but one. This prevents your miners from digging out a few tiles on one level, then running down/up the stairs to do a few tiles on an adjacent level. With only one level "live" and all other levels in marker mode, your miners can concentrate on one level at a time. You just have to remember to "unmark" a new level when your miners are done with their current one.
* As of DF 0.34.x, it is no longer possible to build doors (d) at the same time that you build adjacent walls (Cw). Doors must now be built *after* walls are constructed for them to be next to. This does not affect the more common case where walls exist as a side-effect of having dug-out a room in a #dig blueprint.
Caveats and limitations
-----------------------
* Buildings will be designated regardless of whether you have the required materials, but if materials are not available when the construction job is picked up by a dwarf, the buildings will be canceled and the designations will disappear. Until the buildingplan plugin can be extended to support all building types, you should use `quickfort orders` to pre-manufacture all the materials you need for a `#build` blueprint before you apply it.
* If you use the `jugs` alias in your `#query`-mode blueprints, be aware that there is no way to differentiate jugs from other types of tools in the game. Therefore, `jugs` stockpiles will also take nest boxes and other tools. The only workaround is not to have other tools lying around in your fort.
* Likewise for bags. The game does not differentiate between empty and full bags, so you'll get bags of gypsum power and sand in your bags stockpile unless you avoid collecting sand and are careful to assign all your gypsum to your hospital.
* Weapon traps and upright spear/spike traps can currently only be built with a single weapon.
* Pressure plates can be built, but they cannot be usefully configured yet.
* Building instruments, bookcases, display furniture, and offering places are not yet supported by DFHack.
* This script is relatively new, and there are bound to be bugs! Please report them at the [DFHack issue tracker](https://github.com/DFHack/dfhack/issues) so they can be addressed.
Links
-----
### Quickfort links ###
* [Quickfort command syntax](https://docs.dfhack.org/en/stable/docs/_auto/base.html#quickfort)
* [Quickfort forum thread](http://www.bay12forums.com/smf/index.php?topic=176889.0)
* [Quickfort blueprints library](https://github.com/DFHack/dfhack/tree/develop/data/blueprints/library)
* [DFHack issue tracker](https://github.com/DFHack/dfhack/issues)
* [Quickfort source code](https://github.com/DFHack/scripts/tree/master/internal/quickfort)
### Related tools ###
* DFHack's [blueprint plugin](https://docs.dfhack.org/en/stable/docs/Plugins.html#blueprint) can generate blueprints from actual DF maps.
* [Python Quickfort](http://joelpt.net/quickfort) is the previous, Python-based implementation that DFHack's quickfort script was inspired by.

@ -33,6 +33,7 @@ Carter Bray Qartar
Chris Dombroski cdombroski Chris Dombroski cdombroski
Clayton Hughes Clayton Hughes
Clément Vuchener cvuchener Clément Vuchener cvuchener
daedsidog daedsidog
Dan Amlund danamlund Dan Amlund danamlund
Daniel Brooks db48x Daniel Brooks db48x
David Nilsolm David Nilsolm
@ -112,6 +113,7 @@ nocico nocico
Omniclasm Omniclasm
OwnageIsMagic OwnageIsMagic OwnageIsMagic OwnageIsMagic
palenerd dlmarquis palenerd dlmarquis
PassionateAngler PassionateAngler
Patrik Lundell PatrikLundell Patrik Lundell PatrikLundell
Paul Fenwick pjf Paul Fenwick pjf
PeridexisErrant PeridexisErrant PeridexisErrant PeridexisErrant
@ -134,6 +136,7 @@ Rinin Rinin
rndmvar rndmvar rndmvar rndmvar
Robert Heinrich rh73 Robert Heinrich rh73
Robert Janetzko robertjanetzko Robert Janetzko robertjanetzko
Rocco Moretti roccomoretti
RocheLimit RocheLimit
rofl0r rofl0r rofl0r rofl0r
root root

@ -80,7 +80,9 @@ system console:
If you use a permanent patch under OSX or Linux, you must update If you use a permanent patch under OSX or Linux, you must update
``symbols.xml`` with the new checksum of the executable. Find the relevant ``symbols.xml`` with the new checksum of the executable. Find the relevant
section, and add a new line:: section, and add a new line:
.. code-block:: xml
<md5-hash value='????????????????????????????????'/> <md5-hash value='????????????????????????????????'/>

@ -1,3 +1,5 @@
.. highlight:: shell
.. _compile: .. _compile:
################ ################
@ -283,7 +285,9 @@ Dwarf Fortress runs, it uses a libstdc++ shipped in the ``libs`` folder, which
comes from GCC 4.8 and is incompatible with code compiled with newer GCC comes from GCC 4.8 and is incompatible with code compiled with newer GCC
versions. As of DFHack 0.42.05-alpha1, the ``dfhack`` launcher script attempts versions. As of DFHack 0.42.05-alpha1, the ``dfhack`` launcher script attempts
to fix this by automatically removing the DF-provided libstdc++ on startup. to fix this by automatically removing the DF-provided libstdc++ on startup.
In rare cases, this may fail and cause errors such as:: In rare cases, this may fail and cause errors such as:
.. code-block:: text
./libs/Dwarf_Fortress: /pathToDF/libs/libstdc++.so.6: version ./libs/Dwarf_Fortress: /pathToDF/libs/libstdc++.so.6: version
`GLIBCXX_3.4.18' not found (required by ./hack/libdfhack.so) `GLIBCXX_3.4.18' not found (required by ./hack/libdfhack.so)
@ -364,7 +368,7 @@ Dependencies and system set-up
both 32-bit and 64-bit variants. Homebrew also doesn't require constant use both 32-bit and 64-bit variants. Homebrew also doesn't require constant use
of ``sudo``. of ``sudo``.
Using `Homebrew <http://brew.sh/>`_ (recommended):: Using `Homebrew <https://brew.sh/>`_ (recommended)::
brew tap homebrew/versions brew tap homebrew/versions
brew install git brew install git
@ -399,14 +403,14 @@ Dependencies and system set-up
* In a separate, local Perl install * In a separate, local Perl install
Rather than using system Perl, you might also want to consider Rather than using system Perl, you might also want to consider
the Perl manager, `Perlbrew <http://perlbrew.pl>`_. the Perl manager, `Perlbrew <https://perlbrew.pl>`_.
This manages Perl 5 locally under ``~/perl5/``, providing an easy This manages Perl 5 locally under ``~/perl5/``, providing an easy
way to install Perl and run CPAN against it without ``sudo``. way to install Perl and run CPAN against it without ``sudo``.
It can maintain multiple Perl installs and being local has the It can maintain multiple Perl installs and being local has the
benefit of easy migration and insulation from OS issues and upgrades. benefit of easy migration and insulation from OS issues and upgrades.
See http://perlbrew.pl/ for more details. See https://perlbrew.pl/ for more details.
Building Building
-------- --------
@ -517,7 +521,7 @@ To install Chocolatey and the required dependencies:
You can now use all of these utilities from any normal ``cmd.exe`` window. You can now use all of these utilities from any normal ``cmd.exe`` window.
You only need Admin/elevated ``cmd.exe`` for running ``choco install`` commands; You only need Admin/elevated ``cmd.exe`` for running ``choco install`` commands;
for all other purposes, including compiling DFHack, you should use for all other purposes, including compiling DFHack, you should use
a normal ``cmd.exe`` (or, better, an improved terminal like `Cmder <http://cmder.net/>`_; a normal ``cmd.exe`` (or, better, an improved terminal like `Cmder <https://cmder.net/>`_;
details below, under Build.) details below, under Build.)
**NOTE**: you can run the above ``choco install`` command even if you already have **NOTE**: you can run the above ``choco install`` command even if you already have
@ -544,7 +548,7 @@ Some examples:
CMake CMake
^^^^^ ^^^^^
You can get the win32 installer version from You can get the win32 installer version from
`the official site <http://www.cmake.org/cmake/resources/software.html>`_. `the official site <https://cmake.org/download/>`_.
It has the usual installer wizard. Make sure you let it add its binary folder It has the usual installer wizard. Make sure you let it add its binary folder
to your binary search PATH so the tool can be later run from anywhere. to your binary search PATH so the tool can be later run from anywhere.
@ -617,7 +621,7 @@ due to the tiny window size and extremely limited scrollback. For that reason yo
may prefer to compile in the IDE which will always show all build output. may prefer to compile in the IDE which will always show all build output.
Alternatively (or additionally), consider installing an improved Windows terminal Alternatively (or additionally), consider installing an improved Windows terminal
such as `Cmder <http://cmder.net/>`_. Easily installed through Chocolatey with: such as `Cmder <https://cmder.net/>`_. Easily installed through Chocolatey with:
``choco install cmder -y``. ``choco install cmder -y``.
**Note for Cygwin/msysgit users**: It is also possible to compile DFHack from a **Note for Cygwin/msysgit users**: It is also possible to compile DFHack from a

@ -63,7 +63,9 @@ or at any other time using the ``dfhack-run`` executable.
If DF/DFHack is started with arguments beginning with ``+``, the remaining If DF/DFHack is started with arguments beginning with ``+``, the remaining
text is treated as a command in the DFHack console. It is possible to use text is treated as a command in the DFHack console. It is possible to use
multiple such commands, which are split on ``+``. For example:: multiple such commands, which are split on ``+``. For example:
.. code-block:: shell
./dfhack +load-save region1 ./dfhack +load-save region1
"Dwarf Fortress.exe" +devel/print-args Hello! +enable workflow "Dwarf Fortress.exe" +devel/print-args Hello! +enable workflow
@ -93,7 +95,9 @@ but ``dfhack-run`` can be useful in a variety of circumstances:
- from external programs or scripts - from external programs or scripts
- if DF or DFHack are not responding - if DF or DFHack are not responding
Examples:: Examples:
.. code-block:: shell
./dfhack-run cursecheck ./dfhack-run cursecheck
dfhack-run kill-lua dfhack-run kill-lua
@ -456,7 +460,9 @@ Environment variables
===================== =====================
DFHack's behavior can be adjusted with some environment variables. For example, DFHack's behavior can be adjusted with some environment variables. For example,
on UNIX-like systems:: on UNIX-like systems:
.. code-block:: shell
DFHACK_SOME_VAR=1 ./dfhack DFHACK_SOME_VAR=1 ./dfhack
@ -505,5 +511,5 @@ This section is for odd but important notes that don't fit anywhere else.
Older versions are available here_. Older versions are available here_.
*These files will eventually be migrated to GitHub.* (see :issue:`473`) *These files will eventually be migrated to GitHub.* (see :issue:`473`)
.. _DFFD: http://dffd.bay12games.com/search.php?string=DFHack&id=15&limit=1000 .. _DFFD: https://dffd.bay12games.com/search.php?string=DFHack&id=15&limit=1000
.. _here: http://dethware.org/dfhack/download .. _here: https://dethware.org/dfhack/download

@ -6,13 +6,13 @@ DFHack Documentation System
DFHack documentation, like the file you are reading now, is created as ``.rst`` files, DFHack documentation, like the file you are reading now, is created as ``.rst`` files,
which are in `reStructuredText (reST) <http://sphinx-doc.org/rest.html>`_ format. which are in `reStructuredText (reST) <https://www.sphinx-doc.org/rest.html>`_ format.
This is a documentation format common in the Python community. It is very This is a documentation format common in the Python community. It is very
similar in concept - and in syntax - to Markdown, as found on GitHub and many other similar in concept - and in syntax - to Markdown, as found on GitHub and many other
places. However it is more advanced than Markdown, with more features available when places. However it is more advanced than Markdown, with more features available when
compiled to HTML, such as automatic tables of contents, cross-linking, special compiled to HTML, such as automatic tables of contents, cross-linking, special
external links (forum, wiki, etc) and more. The documentation is compiled by a external links (forum, wiki, etc) and more. The documentation is compiled by a
Python tool, `Sphinx <http://sphinx-doc.org>`_. Python tool, `Sphinx <https://www.sphinx-doc.org>`_.
The DFHack build process will compile the documentation, but this is disabled The DFHack build process will compile the documentation, but this is disabled
by default due to the additional Python and Sphinx requirements. You typically by default due to the additional Python and Sphinx requirements. You typically
@ -57,7 +57,9 @@ as the in-console documentation by (e.g.) printing it when a ``-help`` argument
is given. is given.
The docs **must** have a heading which exactly matches the command, underlined The docs **must** have a heading which exactly matches the command, underlined
with ``=====`` to the same length. For example, a lua file would have:: with ``=====`` to the same length. For example, a lua file would have:
.. code-block:: lua
local helpstr = [====[ local helpstr = [====[
@ -69,6 +71,8 @@ with ``=====`` to the same length. For example, a lua file would have::
]====] ]====]
.. highlight:: rst
Where the heading for a section is also the name of a command, the spelling Where the heading for a section is also the name of a command, the spelling
and case should exactly match the command to enter in the DFHack command line. and case should exactly match the command to enter in the DFHack command line.
@ -118,6 +122,8 @@ Scripts have link targets created automatically.
Building the documentation Building the documentation
========================== ==========================
.. highlight:: shell
Required dependencies Required dependencies
--------------------- ---------------------
In order to build the documentation, you must have Python with Sphinx In order to build the documentation, you must have Python with Sphinx

@ -227,7 +227,7 @@ Internals
Lua Lua
--- ---
- Lua has been updated to 5.3 - see http://www.lua.org/manual/5.3/readme.html for details - Lua has been updated to 5.3 - see https://www.lua.org/manual/5.3/readme.html for details
- Floats are no longer implicitly converted to integers in DFHack API calls - Floats are no longer implicitly converted to integers in DFHack API calls

@ -8,7 +8,7 @@ DFHack is a Dwarf Fortress memory access library, distributed with
a wide variety of useful scripts and plugins. a wide variety of useful scripts and plugins.
The project is currently hosted `on GitHub <https://www.github.com/DFHack/dfhack>`_, The project is currently hosted `on GitHub <https://www.github.com/DFHack/dfhack>`_,
and can be downloaded from `the releases page <http://github.com/DFHack/dfhack/releases>`_ and can be downloaded from `the releases page <https://github.com/DFHack/dfhack/releases>`_
- see `installing` for installation instructions. This is also where the - see `installing` for installation instructions. This is also where the
`DFHack bug tracker <https://www.github.com/DFHack/dfhack>`_ is hosted. `DFHack bug tracker <https://www.github.com/DFHack/dfhack>`_ is hosted.

@ -1,3 +1,5 @@
.. highlight:: lua
.. _lua-api: .. _lua-api:
############## ##############
@ -7,7 +9,7 @@ DFHack Lua API
DFHack has extensive support for DFHack has extensive support for
the Lua_ scripting language, providing access to: the Lua_ scripting language, providing access to:
.. _Lua: http://www.lua.org .. _Lua: https://www.lua.org
1. Raw data structures used by the game. 1. Raw data structures used by the game.
2. Many C++ functions for high-level access to these 2. Many C++ functions for high-level access to these
@ -37,7 +39,7 @@ DF data structure wrapper
:local: :local:
Data structures of the game are defined in XML files located in :file:`library/xml` Data structures of the game are defined in XML files located in :file:`library/xml`
(and `online <http://github.com/DFHack/df-structures>`_, and automatically exported (and `online <https://github.com/DFHack/df-structures>`_, and automatically exported
to lua code as a tree of objects and functions under the ``df`` global, which to lua code as a tree of objects and functions under the ``df`` global, which
also broadly maps to the ``df`` namespace in the headers generated for C++. also broadly maps to the ``df`` namespace in the headers generated for C++.
@ -879,14 +881,23 @@ can be omitted.
Convert a string from DF's CP437 encoding to the correct encoding for the Convert a string from DF's CP437 encoding to the correct encoding for the
DFHack console. DFHack console.
.. warning::
When printing CP437-encoded text to the console (for example, names returned
from ``dfhack.TranslateName()``), use ``print(dfhack.df2console(text))`` to
ensure proper display on all platforms.
* ``dfhack.utf2df(string)`` * ``dfhack.utf2df(string)``
Convert a string from UTF-8 to DF's CP437 encoding. Convert a string from UTF-8 to DF's CP437 encoding.
**Note:** When printing CP437-encoded text to the console (for example, names * ``dfhack.toSearchNormalized(string)``
returned from TranslateName()), use ``print(dfhack.df2console(text)`` to ensure
proper display on all platforms.
Replace non-ASCII alphabetic characters in a CP437-encoded string with their
nearest ASCII equivalents, if possible, and returns a CP437-encoded string.
Note that the returned string may be longer than the input string. For
example, ``ä`` is replaced with ``a``, and ``æ`` is replaced with ``ae``.
Gui module Gui module
---------- ----------
@ -3754,6 +3765,9 @@ Eventful
This plugin exports some events to lua thus allowing to run lua functions This plugin exports some events to lua thus allowing to run lua functions
on DF world events. on DF world events.
.. contents::
:local:
List of events List of events
-------------- --------------
@ -3914,6 +3928,9 @@ Building-hacks
This plugin overwrites some methods in workshop df class so that mechanical workshops are possible. Although This plugin overwrites some methods in workshop df class so that mechanical workshops are possible. Although
plugin export a function it's recommended to use lua decorated function. plugin export a function it's recommended to use lua decorated function.
.. contents::
:local:
Functions Functions
--------- ---------
@ -3993,6 +4010,9 @@ Luasocket
A way to access csocket from lua. The usage is made similar to luasocket in vanilla lua distributions. Currently A way to access csocket from lua. The usage is made similar to luasocket in vanilla lua distributions. Currently
only subset of functions exist and only tcp mode is implemented. only subset of functions exist and only tcp mode is implemented.
.. contents::
:local:
Socket class Socket class
------------ ------------
@ -4075,6 +4095,9 @@ cxxrandom
Exposes some features of the C++11 random number library to Lua. Exposes some features of the C++11 random number library to Lua.
.. contents::
:local:
Native functions (exported to Lua) Native functions (exported to Lua)
---------------------------------- ----------------------------------

@ -119,7 +119,9 @@ GDB
`GDB <https://www.gnu.org/software/gdb/>`_ is technically cross-platform, but `GDB <https://www.gnu.org/software/gdb/>`_ is technically cross-platform, but
tends to work best on Linux, and DFHack currently only offers support for using tends to work best on Linux, and DFHack currently only offers support for using
GDB on 64-bit Linux. To start with GDB, pass ``-g`` to the DFHack launcher GDB on 64-bit Linux. To start with GDB, pass ``-g`` to the DFHack launcher
script:: script:
.. code-block:: shell
./dfhack -g ./dfhack -g

@ -1443,7 +1443,9 @@ can be displayed on the main fortress mode screen:
The file :file:`dfhack-config/dwarfmonitor.json` can be edited to control the The file :file:`dfhack-config/dwarfmonitor.json` can be edited to control the
positions and settings of all widgets displayed. This file should contain a positions and settings of all widgets displayed. This file should contain a
JSON object with the key ``widgets`` containing an array of objects - see the JSON object with the key ``widgets`` containing an array of objects - see the
included file in the ``dfhack-config`` folder for an example:: included file in the ``dfhack-config`` folder for an example:
.. code-block:: lua
{ {
"widgets": [ "widgets": [
@ -1577,6 +1579,8 @@ Options:
:nick: Mass-assign nicknames, must be followed by the name you want :nick: Mass-assign nicknames, must be followed by the name you want
to set. to set.
:remnick: Mass-remove nicknames. :remnick: Mass-remove nicknames.
:enumnick: Assign enumerated nicknames (e.g. "Hen 1", "Hen 2"...). Must be
followed by the prefix to use in nicknames.
:tocages: Assign unit(s) to cages inside a pasture. :tocages: Assign unit(s) to cages inside a pasture.
:uinfo: Print info about unit(s). If no filters are set a unit must :uinfo: Print info about unit(s). If no filters are set a unit must
be selected in the in-game ui. be selected in the in-game ui.
@ -2646,6 +2650,8 @@ custom reaction raws, with the following differences:
* If the item has no subtype, the ``:NONE`` can be omitted * If the item has no subtype, the ``:NONE`` can be omitted
* If the item is ``REMAINS``, ``FISH``, ``FISH_RAW``, ``VERMIN``, ``PET``, or ``EGG``, * If the item is ``REMAINS``, ``FISH``, ``FISH_RAW``, ``VERMIN``, ``PET``, or ``EGG``,
specify a ``CREATURE:CASTE`` pair instead of a material token. specify a ``CREATURE:CASTE`` pair instead of a material token.
* If the item is a ``PLANT_GROWTH``, specify a ``PLANT_ID:GROWTH_ID`` pair
instead of a material token.
Corpses, body parts, and prepared meals cannot be created using this tool. Corpses, body parts, and prepared meals cannot be created using this tool.
@ -2664,6 +2670,10 @@ Examples:
createitem WOOD PLANT_MAT:TOWER_CAP:WOOD createitem WOOD PLANT_MAT:TOWER_CAP:WOOD
* Create bilberries::
createitem PLANT_GROWTH BILBERRY:FRUIT
For more examples, :wiki:`see this wiki page <Utility:DFHack/createitem>`. For more examples, :wiki:`see this wiki page <Utility:DFHack/createitem>`.
To change where new items are placed, first run the command with a To change where new items are placed, first run the command with a

@ -33,6 +33,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
# Future # Future
# 0.47.04-r3
## New Plugins ## New Plugins
- `xlsxreader`: provides an API for Lua scripts to read Excel spreadsheets - `xlsxreader`: provides an API for Lua scripts to read Excel spreadsheets
@ -41,10 +43,22 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
- `getplants`: fixed a crash that could occur on some maps - `getplants`: fixed a crash that could occur on some maps
- `search`: fixed an issue causing item counts on the trade screen to display inconsistently when searching - `search`: fixed an issue causing item counts on the trade screen to display inconsistently when searching
- `stockpiles`: fixed a crash when loading food stockpiles - `stockpiles`: fixed a crash when loading food stockpiles
- `stockpiles`: fixed an error when saving furniture stockpiles
## Misc Improvements ## Misc Improvements
- `createitem`: added support for plant growths (fruit, berries, leaves, etc.)
- `createitem`: added an ``inspect`` subcommand to print the item and material tokens of existing items, which can be used to create additional matching items - `createitem`: added an ``inspect`` subcommand to print the item and material tokens of existing items, which can be used to create additional matching items
- `embark-assistant`: added support for searching for taller waterfalls (up to 50 z-levels tall) - `embark-assistant`: added support for searching for taller waterfalls (up to 50 z-levels tall)
- `search`: added support for searching for names containing non-ASCII characters using their ASCII equivalents
- `stocks`: added support for searching for items containing non-ASCII characters using their ASCII equivalents
- `zone`: added an ``enumnick`` subcommand to assign enumerated nicknames (e.g "Hen 1", "Hen 2"...)
- `zone`: added slaughter indication to ``uinfo`` output
## Documentation
- Fixed syntax highlighting of most code blocks to use the appropriate language (or no language) instead of Python
## API
- Added ``DFHack::to_search_normalized()`` (Lua: ``dfhack.toSearchNormalized()``) to convert non-ASCII alphabetic characters to their ASCII equivalents
# 0.47.04-r2 # 0.47.04-r2

@ -0,0 +1,11 @@
===========
User Guides
===========
These pages are detailed guides covering DFHack tools.
.. toctree::
:maxdepth: 1
:glob:
*

File diff suppressed because it is too large Load Diff

@ -0,0 +1,34 @@
# adapted from:
# https://stackoverflow.com/a/16470058
# https://pygments.org/docs/lexerdevelopment/
import re
from pygments.lexer import RegexLexer
from pygments.token import Comment, Generic, Text
from sphinx.highlighting import lexers
class DFHackLexer(RegexLexer):
name = 'DFHack'
aliases = ['dfhack']
flags = re.IGNORECASE | re.MULTILINE
tokens = {
'root': [
(r'\#.+$', Comment.Single),
(r'^\[[a-z]+\]\# ', Generic.Prompt),
(r'.+?', Text),
]
}
def register_lexer(app):
lexers['dfhack'] = DFHackLexer()
def setup(app):
app.connect('builder-inited', register_lexer)
return {
'version': '0.1',
'parallel_read_safe': True,
'parallel_write_safe': True,
}

@ -61,3 +61,7 @@ div.body li > p {
margin-top: 0; margin-top: 0;
margin-bottom: 0; margin-bottom: 0;
} }
span.pre {
overflow-wrap: break-word;
}

@ -31,5 +31,6 @@ User Manual
/docs/Core /docs/Core
/docs/Plugins /docs/Plugins
/docs/Scripts /docs/Scripts
/docs/guides/index
/docs/index-about /docs/index-about
/docs/index-dev /docs/index-dev

@ -1417,6 +1417,7 @@ static bool isMapLoaded() { return Core::getInstance().isMapLoaded(); }
static std::string df2utf(std::string s) { return DF2UTF(s); } static std::string df2utf(std::string s) { return DF2UTF(s); }
static std::string utf2df(std::string s) { return UTF2DF(s); } static std::string utf2df(std::string s) { return UTF2DF(s); }
static std::string df2console(color_ostream &out, std::string s) { return DF2CONSOLE(out, s); } static std::string df2console(color_ostream &out, std::string s) { return DF2CONSOLE(out, s); }
static std::string toSearchNormalized(std::string s) { return to_search_normalized(s); }
#define WRAP_VERSION_FUNC(name, function) WRAPN(name, DFHack::Version::function) #define WRAP_VERSION_FUNC(name, function) WRAPN(name, DFHack::Version::function)
@ -1434,6 +1435,7 @@ static const LuaWrapper::FunctionReg dfhack_module[] = {
WRAP(df2utf), WRAP(df2utf),
WRAP(utf2df), WRAP(utf2df),
WRAP(df2console), WRAP(df2console),
WRAP(toSearchNormalized),
WRAP_VERSION_FUNC(getDFHackVersion, dfhack_version), WRAP_VERSION_FUNC(getDFHackVersion, dfhack_version),
WRAP_VERSION_FUNC(getDFHackRelease, dfhack_release), WRAP_VERSION_FUNC(getDFHackRelease, dfhack_release),
WRAP_VERSION_FUNC(getDFHackBuildID, dfhack_build_id), WRAP_VERSION_FUNC(getDFHackBuildID, dfhack_build_id),

@ -128,6 +128,46 @@ std::string toLower(const std::string &str)
return rv; return rv;
} }
static const char *normalized_table[256] = {
//.0 .1 .2 .3 .4 .5 .6 .7 .8 .9 .A .B .C .D .E .F
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 0.
NULL, NULL, NULL, NULL, NULL, "S", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 1.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 2.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 3.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 4.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 5.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 6.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // 7.
"C", "u", "e", "a", "a", "a", "a", "c", "e", "e", "e", "i", "i", "i", "A", "A", // 8.
"E", "ae", "Ae", "o", "o", "o", "u", "u", "y", "O", "U", "c", "L", "Y", NULL, "f", // 9.
"a", "i", "o", "u", "n", "N", "a", "o", NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // A.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // B.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // C.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // D.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // E.
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, // F.
};
std::string to_search_normalized(const std::string &str)
{
std::string result;
result.reserve(str.size());
for (char c : str)
{
const char *mapped = normalized_table[(uint8_t)c];
if (mapped == NULL)
result += tolower(c);
else
while (*mapped != '\0')
{
result += tolower(*mapped);
++mapped;
}
}
return result;
}
bool word_wrap(std::vector<std::string> *out, const std::string &str, size_t line_length) bool word_wrap(std::vector<std::string> *out, const std::string &str, size_t line_length)
{ {
out->clear(); out->clear();

@ -366,6 +366,7 @@ DFHACK_EXPORT std::string join_strings(const std::string &separator, const std::
DFHACK_EXPORT std::string toUpper(const std::string &str); DFHACK_EXPORT std::string toUpper(const std::string &str);
DFHACK_EXPORT std::string toLower(const std::string &str); DFHACK_EXPORT std::string toLower(const std::string &str);
DFHACK_EXPORT std::string to_search_normalized(const std::string &str);
DFHACK_EXPORT bool word_wrap(std::vector<std::string> *out, DFHACK_EXPORT bool word_wrap(std::vector<std::string> *out,
const std::string &str, const std::string &str,

@ -178,7 +178,7 @@ std::string ItemTypeInfo::getToken()
std::string rv = ENUM_KEY_STR(item_type, type); std::string rv = ENUM_KEY_STR(item_type, type);
if (custom) if (custom)
rv += ":" + custom->id; rv += ":" + custom->id;
else if (subtype != -1) else if (subtype != -1 && type != item_type::PLANT_GROWTH)
rv += stl_sprintf(":%d", subtype); rv += stl_sprintf(":%d", subtype);
return rv; return rv;
} }

@ -1 +1 @@
Subproject commit 5756bf8599630891fc460b1509bd0660b71c0809 Subproject commit 00549aca0640ca121c20734df667f79b247c93b4

@ -26,6 +26,9 @@
#include "df/reaction_reagent.h" #include "df/reaction_reagent.h"
#include "df/reaction_product_itemst.h" #include "df/reaction_product_itemst.h"
#include "df/tool_uses.h" #include "df/tool_uses.h"
#include "df/item_plant_growthst.h"
#include "df/plant_growth.h"
#include "df/plant_growth_print.h"
using std::string; using std::string;
using std::vector; using std::vector;
@ -37,6 +40,7 @@ REQUIRE_GLOBAL(cursor);
REQUIRE_GLOBAL(world); REQUIRE_GLOBAL(world);
REQUIRE_GLOBAL(ui); REQUIRE_GLOBAL(ui);
REQUIRE_GLOBAL(gametype); REQUIRE_GLOBAL(gametype);
REQUIRE_GLOBAL(cur_year_tick);
int dest_container = -1, dest_building = -1; int dest_container = -1, dest_building = -1;
@ -51,6 +55,7 @@ DFhackCExport command_result plugin_init (color_ostream &out, std::vector<Plugin
" <material> - The material you want the item to be made of, as specified\n" " <material> - The material you want the item to be made of, as specified\n"
" in custom reactions. For REMAINS, FISH, FISH_RAW, VERMIN,\n" " in custom reactions. For REMAINS, FISH, FISH_RAW, VERMIN,\n"
" PET, and EGG, replace this with a creature ID and caste.\n" " PET, and EGG, replace this with a creature ID and caste.\n"
" For PLANT_GROWTH, replace this with a plant ID and growth ID.\n"
" [count] - How many of the item you wish to create.\n" " [count] - How many of the item you wish to create.\n"
"\n" "\n"
"To obtain the item and material of an existing item, run \n" "To obtain the item and material of an existing item, run \n"
@ -72,7 +77,7 @@ DFhackCExport command_result plugin_shutdown ( color_ostream &out )
return CR_OK; return CR_OK;
} }
bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_item = false, bool move_to_cursor = false) bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_item = false, bool move_to_cursor = false, int32_t growth_print = -1)
{ {
vector<df::reaction_product*> out_products; vector<df::reaction_product*> out_products;
vector<df::item *> out_items; vector<df::item *> out_items;
@ -118,6 +123,8 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_it
out_items[i]->moveToGround(cursor->x, cursor->y, cursor->z); out_items[i]->moveToGround(cursor->x, cursor->y, cursor->z);
else else
out_items[i]->moveToGround(unit->pos.x, unit->pos.y, unit->pos.z); out_items[i]->moveToGround(unit->pos.x, unit->pos.y, unit->pos.z);
// Special logic for making gloves
if (is_gloves) if (is_gloves)
{ {
// if the reaction creates gloves without handedness, then create 2 sets (left and right) // if the reaction creates gloves without handedness, then create 2 sets (left and right)
@ -126,9 +133,14 @@ bool makeItem (df::reaction_product_itemst *prod, df::unit *unit, bool second_it
else else
out_items[i]->setGloveHandedness(second_item ? 2 : 1); out_items[i]->setGloveHandedness(second_item ? 2 : 1);
} }
// Special logic for making plant growths
auto growth = virtual_cast<df::item_plant_growthst>(out_items[i]);
if (growth)
growth->growth_print = growth_print;
} }
if ((is_gloves || is_shoes) && !second_item) if ((is_gloves || is_shoes) && !second_item)
return makeItem(prod, unit, true, move_to_cursor); return makeItem(prod, unit, true, move_to_cursor, growth_print);
return true; return true;
} }
@ -140,6 +152,7 @@ command_result df_createitem (color_ostream &out, vector <string> & parameters)
int16_t item_subtype = -1; int16_t item_subtype = -1;
int16_t mat_type = -1; int16_t mat_type = -1;
int32_t mat_index = -1; int32_t mat_index = -1;
int32_t growth_print = -1;
int count = 1; int count = 1;
bool move_to_cursor = false; bool move_to_cursor = false;
@ -370,6 +383,77 @@ command_result df_createitem (color_ostream &out, vector <string> & parameters)
} }
break; break;
case item_type::PLANT_GROWTH:
split_string(&tokens, material_str, ":");
if (tokens.size() == 1)
{
// default to empty to display a list of valid growths later
tokens.push_back("");
}
else if (tokens.size() == 3 && tokens[0] == "PLANT")
{
tokens.erase(tokens.begin());
}
else if (tokens.size() != 2)
{
out.printerr("You must specify a plant and growth ID for this item type!\n");
return CR_FAILURE;
}
for (size_t i = 0; i < world->raws.plants.all.size(); i++)
{
string growths = "";
df::plant_raw *plant = world->raws.plants.all[i];
if (plant->id != tokens[0])
continue;
for (size_t j = 0; j < plant->growths.size(); j++)
{
df::plant_growth *growth = plant->growths[j];
growths += " " + growth->id;
if (growth->id != tokens[1])
continue;
// Plant growths specify the actual item type/subtype
// so that certain growths can drop as SEEDS items
item_type = growth->item_type;
item_subtype = growth->item_subtype;
mat_type = growth->mat_type;
mat_index = growth->mat_index;
// Try and find a growth print matching the current time
// (in practice, only tree leaves use this for autumn color changes)
for (size_t k = 0; k < growth->prints.size(); k++)
{
df::plant_growth_print *print = growth->prints[k];
if (print->timing_start <= *cur_year_tick && *cur_year_tick <= print->timing_end)
{
growth_print = k;
break;
}
}
// If we didn't find one, then pick the first one (if it exists)
if (growth_print == -1 && growth->prints.size() > 0)
growth_print = 0;
break;
}
if (mat_type == -1)
{
if (tokens[1].empty())
out.printerr("You must also specify a growth ID.\n");
else
out.printerr("The plant you specified has no such growth!\n");
out.printerr("Valid growths:%s\n", growths.c_str());
return CR_FAILURE;
}
}
if (mat_type == -1)
{
out.printerr("Unrecognized plant ID!\n");
return CR_FAILURE;
}
break;
case item_type::CORPSE: case item_type::CORPSE:
case item_type::CORPSEPIECE: case item_type::CORPSEPIECE:
case item_type::FOOD: case item_type::FOOD:
@ -449,7 +533,7 @@ command_result df_createitem (color_ostream &out, vector <string> & parameters)
out.printerr("Previously selected building no longer exists - item will be placed on the floor.\n"); out.printerr("Previously selected building no longer exists - item will be placed on the floor.\n");
} }
bool result = makeItem(prod, unit, false, move_to_cursor); bool result = makeItem(prod, unit, false, move_to_cursor, growth_print);
delete prod; delete prod;
if (!result) if (!result)
{ {

@ -139,14 +139,14 @@ public:
virtual void tokenizeSearch (vector<string> *dest, const string search) virtual void tokenizeSearch (vector<string> *dest, const string search)
{ {
if (!search.empty()) if (!search.empty())
split_string(dest, search, " "); split_string(dest, to_search_normalized(search), " ");
} }
virtual bool showEntry(const ListEntry<T> *entry, const vector<string> &search_tokens) virtual bool showEntry(const ListEntry<T> *entry, const vector<string> &search_tokens)
{ {
if (!search_tokens.empty()) if (!search_tokens.empty())
{ {
string item_string = toLower(entry->text); string item_string = to_search_normalized(entry->text);
for (auto si = search_tokens.begin(); si != search_tokens.end(); si++) for (auto si = search_tokens.begin(); si != search_tokens.end(); si++)
{ {
if (!si->empty() && item_string.find(*si) == string::npos && if (!si->empty() && item_string.find(*si) == string::npos &&
@ -164,9 +164,9 @@ public:
ListEntry<T> *prev_selected = (getDisplayListSize() > 0) ? display_list[highlighted_index] : NULL; ListEntry<T> *prev_selected = (getDisplayListSize() > 0) ? display_list[highlighted_index] : NULL;
display_list.clear(); display_list.clear();
search_string = toLower(search_string); search_string = to_search_normalized(search_string);
vector<string> search_tokens; vector<string> search_tokens;
tokenizeSearch(&search_tokens, search_string); tokenizeSearch(&search_tokens, to_search_normalized(search_string));
for (size_t i = 0; i < list.size(); i++) for (size_t i = 0; i < list.size(); i++)
{ {

@ -396,7 +396,7 @@ protected:
clear_viewscreen_vectors(); clear_viewscreen_vectors();
string search_string_l = toLower(search_string); string search_string_l = to_search_normalized(search_string);
for (size_t i = 0; i < saved_list1.size(); i++ ) for (size_t i = 0; i < saved_list1.size(); i++ )
{ {
if (force_in_search(i)) if (force_in_search(i))
@ -409,7 +409,7 @@ protected:
continue; continue;
T element = saved_list1[i]; T element = saved_list1[i];
string desc = toLower(get_element_description(element)); string desc = to_search_normalized(get_element_description(element));
if (desc.find(search_string_l) != string::npos) if (desc.find(search_string_l) != string::npos)
{ {
add_to_filtered_list(i); add_to_filtered_list(i);

@ -866,7 +866,6 @@ static command_result tweak(color_ostream &out, vector <string> &parameters)
} }
// case #1: migrants who have the resident flag set // case #1: migrants who have the resident flag set
// see http://dffd.wimbli.com/file.php?id=6139 for a save
if (unit->flags2.bits.resident) if (unit->flags2.bits.resident)
unit->flags2.bits.resident = 0; unit->flags2.bits.resident = 0;

@ -133,6 +133,7 @@ const string zone_help =
" with filters named units are ignored unless specified.\n" " with filters named units are ignored unless specified.\n"
" unassign - unassign selected creature(s) from zone or cage\n" " unassign - unassign selected creature(s) from zone or cage\n"
" nick - give unit(s) nicknames (e.g. all units in a cage)\n" " nick - give unit(s) nicknames (e.g. all units in a cage)\n"
" enumnick - give unit(s) enumerated nicknames (e.g Hen 1, Hen 2)\n"
" remnick - remove nicknames\n" " remnick - remove nicknames\n"
" tocages - assign to (multiple) built cages inside a pen/pasture\n" " tocages - assign to (multiple) built cages inside a pen/pasture\n"
" spreads creatures evenly among cages for faster hauling.\n" " spreads creatures evenly among cages for faster hauling.\n"
@ -427,6 +428,7 @@ void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
out << ")"; out << ")";
out << ", age: " << getAge(unit, true); out << ", age: " << getAge(unit, true);
if(isTame(unit)) if(isTame(unit))
out << ", tame"; out << ", tame";
if(isOwnCiv(unit)) if(isOwnCiv(unit))
@ -445,7 +447,9 @@ void unitInfo(color_ostream & out, df::unit* unit, bool verbose = false)
out << ", grazer"; out << ", grazer";
if(isMilkable(unit)) if(isMilkable(unit))
out << ", milkable"; out << ", milkable";
if(unit->flags2.bits.slaughter)
out << ", slaughter";
if(verbose) if(verbose)
{ {
out << ". Pos: ("<<unit->pos.x << "/"<< unit->pos.y << "/" << unit->pos.z << ") " << endl; out << ". Pos: ("<<unit->pos.x << "/"<< unit->pos.y << "/" << unit->pos.z << ") " << endl;
@ -1398,7 +1402,7 @@ pair<string, function<bool(df::unit*)>> createAgeFilter(vector<string> &filter_a
pair<string, function<bool(df::unit*)>> createMinAgeFilter(vector<string> &filter_args) pair<string, function<bool(df::unit*)>> createMinAgeFilter(vector<string> &filter_args)
{ {
int min_age; double min_age;
stringstream ss(filter_args[0]); stringstream ss(filter_args[0]);
ss >> min_age; ss >> min_age;
@ -1424,7 +1428,7 @@ pair<string, function<bool(df::unit*)>> createMinAgeFilter(vector<string> &filte
pair<string, function<bool(df::unit*)>> createMaxAgeFilter(vector<string> &filter_args) pair<string, function<bool(df::unit*)>> createMaxAgeFilter(vector<string> &filter_args)
{ {
int max_age; double max_age;
stringstream ss(filter_args[0]); stringstream ss(filter_args[0]);
ss >> max_age; ss >> max_age;
@ -1489,6 +1493,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
bool cagezone_assign = false; bool cagezone_assign = false;
bool nick_set = false; bool nick_set = false;
string target_nick; string target_nick;
bool enum_nick = true;
string enum_prefix;
bool verbose = false; bool verbose = false;
@ -1694,6 +1700,18 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
start_index = 2; start_index = 2;
out << "Set nickname to: " << target_nick << endl; out << "Set nickname to: " << target_nick << endl;
} }
else if(p0 == "enumnick")
{
if(parameters.size() <= 2)
{
out.printerr("No prefix specified! Use 'remnick' to remove nicknames!\n");
return CR_WRONG_USAGE;
}
enum_nick = true;
enum_prefix = parameters[1];
start_index = 2;
out << "Set nickname to: " << enum_prefix <<" <N>" << endl;
}
else if(p0 == "remnick") else if(p0 == "remnick")
{ {
nick_set = true; nick_set = true;
@ -2070,6 +2088,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
{ {
vector <df::unit*> units_for_cagezone; vector <df::unit*> units_for_cagezone;
int count = 0; int count = 0;
int matchedCount = 0;
for(auto unit_it = world->units.all.begin(); unit_it != world->units.all.end(); ++unit_it) for(auto unit_it = world->units.all.begin(); unit_it != world->units.all.end(); ++unit_it)
{ {
df::unit *unit = *unit_it; df::unit *unit = *unit_it;
@ -2108,6 +2127,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
} }
continue; continue;
} }
matchedCount++;
if(unit_info) if(unit_info)
{ {
@ -2118,6 +2139,12 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
{ {
Units::setNickname(unit, target_nick); Units::setNickname(unit, target_nick);
} }
else if(enum_nick)
{
std::stringstream ss;
ss << enum_prefix << " " << matchedCount;
Units::setNickname(unit, ss.str());
}
else if(cagezone_assign) else if(cagezone_assign)
{ {
units_for_cagezone.push_back(unit); units_for_cagezone.push_back(unit);
@ -2181,6 +2208,7 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
} }
out.color(COLOR_BLUE); out.color(COLOR_BLUE);
out << "Matched creatures: " << matchedCount << endl;
out << "Processed creatures: " << count << endl; out << "Processed creatures: " << count << endl;
out.reset_color(); out.reset_color();
} }

@ -1 +1 @@
Subproject commit 0d7fbec48e959ba88c885975aecbb034fa5f5c57 Subproject commit 0b274855424e5d0850d2cfc8b10e1cdcc47c6877

@ -0,0 +1,8 @@
function test.toSearchNormalized()
expect.eq(dfhack.toSearchNormalized(''), '')
expect.eq(dfhack.toSearchNormalized('abcd'), 'abcd')
expect.eq(dfhack.toSearchNormalized('ABCD'), 'abcd')
expect.eq(dfhack.toSearchNormalized(dfhack.utf2df('áçèîöü')), 'aceiou')
expect.eq(dfhack.toSearchNormalized(dfhack.utf2df('ÄÇÉÖÜÿ')), 'aceouy')
expect.eq(dfhack.toSearchNormalized(dfhack.utf2df('æÆ')), 'aeae')
end