diff options
| -rw-r--r-- | CMakeLists.txt | 40 | ||||
| -rw-r--r-- | Compile.html | 554 | ||||
| -rw-r--r-- | Contributors.html | 391 | ||||
| -rw-r--r-- | LUA Api.html | 2104 | ||||
| -rw-r--r-- | Readme.html | 2808 | ||||
| -rwxr-xr-x | fixTexts.sh | 6 | ||||
| -rwxr-xr-x | testTexts.sh | 5 |
7 files changed, 5883 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 8e69111d..c1ced670 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,31 +147,31 @@ add_subdirectory(depends) find_package(Docutils) -set (RST_FILES -"Readme" -"Compile" -"LUA Api" -"Contributors" -) - -set (RST_PROCESSED_FILES "") -IF(RST2HTML_EXECUTABLE) - foreach(F ${RST_FILES}) - add_custom_command( - OUTPUT "${dfhack_BINARY_DIR}/${F}.html" - COMMAND ${RST2HTML_EXECUTABLE} "${dfhack_SOURCE_DIR}/${F}.rst" > "${dfhack_BINARY_DIR}/${F}.html" - COMMENT "Translating ${F} to html" - DEPENDS "${dfhack_SOURCE_DIR}/${F}.rst") - list (APPEND RST_PROCESSED_FILES "${dfhack_BINARY_DIR}/${F}.html") - endforeach() - add_custom_target(HTML_DOCS ALL DEPENDS ${RST_PROCESSED_FILES}) -ENDIF() +#set (RST_FILES +#"Readme" +#"Compile" +#"LUA Api" +#"Contributors" +#) + +#set (RST_PROCESSED_FILES "") +#IF(RST2HTML_EXECUTABLE) +# foreach(F ${RST_FILES}) +# add_custom_command( +# OUTPUT "${dfhack_BINARY_DIR}/${F}.html" +# COMMAND ${RST2HTML_EXECUTABLE} "${dfhack_SOURCE_DIR}/${F}.rst" "${dfhack_BINARY_DIR}/${F}.html" +# COMMENT "Translating ${F} to html" +# DEPENDS "${dfhack_SOURCE_DIR}/${F}.rst") +# list (APPEND RST_PROCESSED_FILES "${dfhack_BINARY_DIR}/${F}.html") +# endforeach() +# add_custom_target(HTML_DOCS ALL DEPENDS ${RST_PROCESSED_FILES}) +#ENDIF() # build the lib itself IF(BUILD_LIBRARY) add_subdirectory (library) ## install the default documentation files - install(FILES LICENSE ${RST_PROCESSED_FILES} DESTINATION ${DFHACK_USERDOC_DESTINATION}) + install(FILES LICENSE "LUA Api.html" Readme.html Compile.html Contributors.html DESTINATION ${DFHACK_USERDOC_DESTINATION}) endif() #build the plugins diff --git a/Compile.html b/Compile.html new file mode 100644 index 00000000..41d40911 --- /dev/null +++ b/Compile.html @@ -0,0 +1,554 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="Docutils 0.9.1: http://docutils.sourceforge.net/" /> +<title>Building DFHACK</title> +<style type="text/css"> + +/* +:Author: David Goodger (goodger@python.org) +:Id: $Id: html4css1.css 7434 2012-05-11 21:06:27Z milde $ +:Copyright: This stylesheet has been placed in the public domain. + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { + overflow: hidden; +} + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin: 0 0 0.5em 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left, .figure.align-left, object.align-left { + clear: left ; + float: left ; + margin-right: 1em } + +img.align-right, .figure.align-right, object.align-right { + clear: right ; + float: right ; + margin-left: 1em } + +img.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left } + +.align-center { + clear: both ; + text-align: center } + +.align-right { + text-align: right } + +/* reset inner alignment in figures */ +div.align-right { + text-align: inherit } + +/* div.align-center * { */ +/* text-align: left } */ + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font: inherit } + +pre.literal-block, pre.doctest-block, pre.math, pre.code { + margin-left: 2em ; + margin-right: 2em } + +pre.code .ln { /* line numbers */ + color: grey; +} + +.code { + background-color: #eeeeee +} + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } + +table.footnote { + border-left: solid 1px black; + margin-left: 1px } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +ul.auto-toc { + list-style-type: none } + +</style> +</head> +<body> +<div class="document" id="building-dfhack"> +<h1 class="title">Building DFHACK</h1> + +<div class="contents topic" id="contents"> +<p class="topic-title first">Contents</p> +<ul class="simple"> +<li><a class="reference internal" href="#linux" id="id4">Linux</a><ul> +<li><a class="reference internal" href="#how-to-get-the-code" id="id5">How to get the code</a></li> +<li><a class="reference internal" href="#dependencies" id="id6">Dependencies</a></li> +<li><a class="reference internal" href="#build" id="id7">Build</a></li> +</ul> +</li> +<li><a class="reference internal" href="#windows" id="id8">Windows</a><ul> +<li><a class="reference internal" href="#id1" id="id9">How to get the code</a></li> +<li><a class="reference internal" href="#id2" id="id10">Dependencies</a></li> +<li><a class="reference internal" href="#id3" id="id11">Build</a></li> +</ul> +</li> +<li><a class="reference internal" href="#build-types" id="id12">Build types</a></li> +<li><a class="reference internal" href="#using-the-library-as-a-developer" id="id13">Using the library as a developer</a><ul> +<li><a class="reference internal" href="#df-data-structure-definitions" id="id14">DF data structure definitions</a></li> +<li><a class="reference internal" href="#remote-access-interface" id="id15">Remote access interface</a></li> +<li><a class="reference internal" href="#contributing-to-dfhack" id="id16">Contributing to DFHack</a><ul> +<li><a class="reference internal" href="#coding-style" id="id17">Coding style</a></li> +<li><a class="reference internal" href="#how-to-get-new-code-into-dfhack" id="id18">How to get new code into DFHack</a></li> +<li><a class="reference internal" href="#memory-research" id="id19">Memory research</a></li> +</ul> +</li> +</ul> +</li> +</ul> +</div> +<div class="section" id="linux"> +<h1><a class="toc-backref" href="#id4">Linux</a></h1> +<p>On Linux, DFHack acts as a library that shadows parts of the SDL API using LD_PRELOAD.</p> +<div class="section" id="how-to-get-the-code"> +<h2><a class="toc-backref" href="#id5">How to get the code</a></h2> +<p>DFHack doesn't have any kind of system of code snapshots in place, so you will have to get code from the github repository using git. +Having a 'git' package installed is the minimal requirement, but some sort of git gui or git integration for your favorite text editor/IDE will certainly help.</p> +<p>The code resides here: <a class="reference external" href="https://github.com/peterix/dfhack">https://github.com/peterix/dfhack</a></p> +<p>If you just want to compile DFHack or work on it by contributing patches, it's quite enough to clone from the read-only address:</p> +<pre class="literal-block"> +git clone git://github.com/peterix/dfhack.git +cd dfhack +git submodule init +git submodule update +</pre> +<p>If you want to get really involved with the development, create an account on github, make a clone there and then use that as your remote repository instead. Detailed instructions are beyond the scope of this document. If you need help, join us on IRC (#dfhack channel on freenode).</p> +</div> +<div class="section" id="dependencies"> +<h2><a class="toc-backref" href="#id6">Dependencies</a></h2> +<p>DFHack is meant to be installed into an existing DF folder, so get one ready.</p> +<p>For building, you need a 32-bit version of GCC. For example, to build DFHack on +a 64-bit distribution like Arch, you'll need the multilib development tools and libraries.</p> +<p>Before you can build anything, you'll also need <tt class="docutils literal">cmake</tt>. It is advisable to also get +<tt class="docutils literal">ccmake</tt> on distributions that split the cmake package into multiple parts.</p> +<p>For the code generation parts, you need perl and the XML::LibXML and XML::LibXSLT perl packages. +You should be able to find them in your distro repositories (on Arch linux 'perl-xml-libxml' and 'perl-xml-libxslt').</p> +</div> +<div class="section" id="build"> +<h2><a class="toc-backref" href="#id7">Build</a></h2> +<p>Building is fairly straightforward. Enter the <tt class="docutils literal">build</tt> folder and start the build like this:</p> +<pre class="literal-block"> +cd build +cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX=/home/user/DF +make install +</pre> +<p>Obviously, replace the install path with path to your DF. This will build the library +along with the normal set of plugins and install them into your DF folder.</p> +<p>Alternatively, you can use ccmake instead of cmake:</p> +<pre class="literal-block"> +cd build +ccmake .. +make install +</pre> +<p>This will show a curses-based interface that lets you set all of the +extra options.</p> +<p>You can also use a cmake-friendly IDE like KDevelop 4 or the cmake-gui +program.</p> +</div> +</div> +<div class="section" id="windows"> +<h1><a class="toc-backref" href="#id8">Windows</a></h1> +<p>On Windows, DFHack replaces the SDL library distributed with DF.</p> +<div class="section" id="id1"> +<h2><a class="toc-backref" href="#id9">How to get the code</a></h2> +<p>DFHack doesn't have any kind of system of code snapshots in place, so you will have to get code from the github repository using git. +You will need some sort of Windows port of git, or a GUI. Some examples:</p> +<blockquote> +<ul class="simple"> +<li><a class="reference external" href="http://code.google.com/p/msysgit/">http://code.google.com/p/msysgit/</a> - this is a command line version of git for windows. Most tutorials on git usage will apply.</li> +<li><a class="reference external" href="http://code.google.com/p/tortoisegit/">http://code.google.com/p/tortoisegit/</a> - this puts a pretty, graphical face on top of msysgit :)</li> +</ul> +</blockquote> +<p>The code resides here: <a class="reference external" href="https://github.com/peterix/dfhack">https://github.com/peterix/dfhack</a></p> +<p>If you just want to compile DFHack or work on it by contributing patches, it's quite enough to clone from the read-only address:</p> +<pre class="literal-block"> +git clone git://github.com/peterix/dfhack.git +cd dfhack +git submodule init +git submodule update +</pre> +<p>The tortoisegit GUI should have the equivalent options included.</p> +<p>If you want to get really involved with the development, create an account on github, make a clone there and then use that as your remote repository instead. Detailed instructions are beyond the scope of this document. If you need help, join us on IRC (#dfhack channel on freenode).</p> +</div> +<div class="section" id="id2"> +<h2><a class="toc-backref" href="#id10">Dependencies</a></h2> +<p>First, you need <tt class="docutils literal">cmake</tt>. Get the win32 installer version from the official +site: <a class="reference external" href="http://www.cmake.org/cmake/resources/software.html">http://www.cmake.org/cmake/resources/software.html</a></p> +<p>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.</p> +<p>You'll need a copy of Microsoft Visual C++ 2010. The Express version is sufficient. +Grab it from Microsoft's site.</p> +<p>For the code generation parts, you'll need perl and XML::LibXML. You can install them like this:</p> +<ul class="simple"> +<li>download and install strawberry perl from <a class="reference external" href="http://strawberryperl.com/">http://strawberryperl.com/</a></li> +<li>reboot so that the system can pick up the new binary path</li> +<li>open a cmd.exe window and run "cpan XML::LibXML" (obviously without the quotes). This can take a while to complete.</li> +<li>Same with "cpan XML::LibXSLT".</li> +</ul> +<p>If you already have a different version of perl (for example the one from cygwin), you can run into some trouble. Either remove the other perl install from PATH, or install libxml and libxslt for it instead. Strawberry perl works though and has all the required packages.</p> +</div> +<div class="section" id="id3"> +<h2><a class="toc-backref" href="#id11">Build</a></h2> +<p>There are several different batch files in the <tt class="docutils literal">build</tt> folder along with a script that's used for picking the DF path.</p> +<p>First, run set_df_path.vbs and point the dialog that pops up at your DF folder that you want to use for development. +Next, run one of the scripts with <tt class="docutils literal">generate</tt> prefix. These create the MSVC solution file(s):</p> +<ul class="simple"> +<li><tt class="docutils literal">all</tt> will create a solution with everything enabled (and the kitchen sink).</li> +<li><tt class="docutils literal">gui</tt> will pop up the cmake gui and let you pick and choose what to build. This is probably what you want most of the time. Set the options you are interested in, then hit configure, then generate. More options can appear after the configure step.</li> +<li><tt class="docutils literal">minimal</tt> will create a minimal solution with just the bare necessities - the main library and standard plugins.</li> +</ul> +<p>Then you can either open the solution with MSVC or use one of the msbuild scripts:</p> +<ul class="simple"> +<li>Scripts with <tt class="docutils literal">build</tt> prefix will only build.</li> +<li>Scripts with <tt class="docutils literal">install</tt> prefix will build DFHack and install it to the previously selected DF path.</li> +<li>Scripts with <tt class="docutils literal">package</tt> prefix will build and create a .zip package of DFHack.</li> +</ul> +<p>When you open the solution in MSVC, make sure you never use the Debug builds. Those aren't +binary-compatible with DF. If you try to use a debug build with DF, you'll only get crashes. +So pick either Release or RelWithDebInfo build and build the INSTALL target.</p> +<p>The <tt class="docutils literal">debug</tt> scripts actually do RelWithDebInfo builds.</p> +</div> +</div> +<div class="section" id="build-types"> +<h1><a class="toc-backref" href="#id12">Build types</a></h1> +<p><tt class="docutils literal">cmake</tt> allows you to pick a build type by changing this +variable: <tt class="docutils literal">CMAKE_BUILD_TYPE</tt></p> +<pre class="literal-block"> +cmake .. -DCMAKE_BUILD_TYPE:string=BUILD_TYPE +</pre> +<p>Without specifying a build type or 'None', cmake uses the +<tt class="docutils literal">CMAKE_CXX_FLAGS</tt> variable for building.</p> +<p>Valid and useful build types include 'Release', 'Debug' and +'RelWithDebInfo'. 'Debug' is not available on Windows.</p> +</div> +<div class="section" id="using-the-library-as-a-developer"> +<h1><a class="toc-backref" href="#id13">Using the library as a developer</a></h1> +<p>Currently, the most direct way to use the library is to write a plugin that can be loaded by it. +All the plugins can be found in the 'plugins' folder. There's no in-depth documentation +on how to write one yet, but it should be easy enough to copy one and just follow the pattern.</p> +<p>Other than through plugins, it is possible to use DFHack via remote access interface, or by writing Lua scripts.</p> +<p>The most important parts of DFHack are the Core, Console, Modules and Plugins.</p> +<ul class="simple"> +<li>Core acts as the centerpiece of DFHack - it acts as a filter between DF and SDL and synchronizes the various plugins with DF.</li> +<li>Console is a thread-safe console that can be used to invoke commands exported by Plugins.</li> +<li>Modules actually describe the way to access information in DF's memory. You can get them from the Core. Most modules are split into two parts: high-level and low-level. Higl-level is mostly method calls, low-level publicly visible pointers to DF's data structures.</li> +<li>Plugins are the tools that use all the other stuff to make things happen. A plugin can have a list of commands that it exports and an onupdate function that will be called each DF game tick.</li> +</ul> +<p>Rudimentary API documentation can be built using doxygen (see build options with <tt class="docutils literal">ccmake</tt> or <tt class="docutils literal"><span class="pre">cmake-gui</span></tt>).</p> +<p>DFHack consists of variously licensed code, but invariably weak copyleft. +The main license is zlib/libpng, some bits are MIT licensed, and some are BSD licensed.</p> +<p>Feel free to add your own extensions and plugins. Contributing back to +the dfhack repository is welcome and the right thing to do :)</p> +<div class="section" id="df-data-structure-definitions"> +<h2><a class="toc-backref" href="#id14">DF data structure definitions</a></h2> +<p>DFHack uses information about the game data structures, represented via xml files in the library/xml/ submodule.</p> +<p>Data structure layouts are described in files following the df.*.xml name pattern. This information is transformed by a perl script into C++ headers describing the structures, and associated metadata for the Lua wrapper. These headers and data are then compiled into the DFHack libraries, thus necessitating a compatibility break every time layouts change; in return it significantly boosts the efficiency and capabilities of DFHack code.</p> +<p>Global object addresses are stored in symbols.xml, which is copied to the dfhack release package and loaded as data at runtime.</p> +</div> +<div class="section" id="remote-access-interface"> +<h2><a class="toc-backref" href="#id15">Remote access interface</a></h2> +<p>DFHack supports remote access by exchanging Google protobuf messages via a TCP socket. Both the core and plugins can define remotely accessible methods. The <tt class="docutils literal"><span class="pre">dfhack-run</span></tt> command uses this interface to invoke ordinary console commands.</p> +<p>Currently the supported set of requests is limited, because the developers don't know what exactly is most useful.</p> +<p>Protocol client implementations exist for Java and C#.</p> +</div> +<div class="section" id="contributing-to-dfhack"> +<h2><a class="toc-backref" href="#id16">Contributing to DFHack</a></h2> +<p>Several things should be kept in mind when contributing to DFHack.</p> +<div class="section" id="coding-style"> +<h3><a class="toc-backref" href="#id17">Coding style</a></h3> +<p>DFhack uses ANSI formatting and four spaces as indentation. Line +endings are UNIX. The files use UTF-8 encoding. Code not following this +won't make me happy, because I'll have to fix it. There's a good chance +I'll make <em>you</em> fix it ;)</p> +</div> +<div class="section" id="how-to-get-new-code-into-dfhack"> +<h3><a class="toc-backref" href="#id18">How to get new code into DFHack</a></h3> +<p>You can send patches or make a clone of the github repo and ask me on +the IRC channel to pull your code in. I'll review it and see if there +are any problems. I'll fix them if they are minor.</p> +<p>Fixes are higher in priority. If you want to work on something, but +don't know what, check out <a class="reference external" href="http://github.com/peterix/dfhack/issues">http://github.com/peterix/dfhack/issues</a> -- +this is also a good place to dump new ideas and/or bugs that need +fixing.</p> +</div> +<div class="section" id="memory-research"> +<h3><a class="toc-backref" href="#id19">Memory research</a></h3> +<p>If you want to do memory research, you'll need some tools and some knowledge. +In general, you'll need a good memory viewer and optionally something +to look at machine code without getting crazy :)</p> +<p>Good windows tools include:</p> +<ul class="simple"> +<li>Cheat Engine</li> +<li>IDA Pro (the free version)</li> +</ul> +<p>Good linux tools:</p> +<ul class="simple"> +<li>angavrilov's df-structures gui (visit us on IRC for details).</li> +<li>edb (Evan's Debugger)</li> +<li>IDA Pro running under wine.</li> +<li>Some of the tools residing in the <tt class="docutils literal">legacy</tt> dfhack branch.</li> +</ul> +<p>Using publicly known information and analyzing the game's data is preferred.</p> +</div> +</div> +</div> +</div> +</body> +</html> diff --git a/Contributors.html b/Contributors.html new file mode 100644 index 00000000..72cb8bdf --- /dev/null +++ b/Contributors.html @@ -0,0 +1,391 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="Docutils 0.9.1: http://docutils.sourceforge.net/" /> +<title>Contributors</title> +<style type="text/css"> + +/* +:Author: David Goodger (goodger@python.org) +:Id: $Id: html4css1.css 7434 2012-05-11 21:06:27Z milde $ +:Copyright: This stylesheet has been placed in the public domain. + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { + overflow: hidden; +} + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin: 0 0 0.5em 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left, .figure.align-left, object.align-left { + clear: left ; + float: left ; + margin-right: 1em } + +img.align-right, .figure.align-right, object.align-right { + clear: right ; + float: right ; + margin-left: 1em } + +img.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left } + +.align-center { + clear: both ; + text-align: center } + +.align-right { + text-align: right } + +/* reset inner alignment in figures */ +div.align-right { + text-align: inherit } + +/* div.align-center * { */ +/* text-align: left } */ + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font: inherit } + +pre.literal-block, pre.doctest-block, pre.math, pre.code { + margin-left: 2em ; + margin-right: 2em } + +pre.code .ln { /* line numbers */ + color: grey; +} + +.code { + background-color: #eeeeee +} + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } + +table.footnote { + border-left: solid 1px black; + margin-left: 1px } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +ul.auto-toc { + list-style-type: none } + +</style> +</head> +<body> +<div class="document" id="contributors"> +<h1 class="title">Contributors</h1> + +<p>The following is a list of people who have contributed to <strong>DFHack</strong>. +If you belong here and are missing please add yourself and send me (peterix) a pull request :-)</p> +<ul class="simple"> +<li>Petr Mrázek <<a class="reference external" href="mailto:peterix@gmail.com">peterix@gmail.com</a>></li> +<li>Alexander Gavrilov <<a class="reference external" href="mailto:angavrilov@gmail.com">angavrilov@gmail.com</a>></li> +<li>doomchild <<a class="reference external" href="mailto:lee.crabtree@gmail.com">lee.crabtree@gmail.com</a>></li> +<li>Quietust <<a class="reference external" href="mailto:quietust@gmail.com">quietust@gmail.com</a>></li> +<li>jj <<a class="reference external" href="mailto:john-git@ofjj.net">john-git@ofjj.net</a>></li> +<li>Warmist <<a class="reference external" href="mailto:warmist@gmail.com">warmist@gmail.com</a>></li> +<li>Robert Heinrich <<a class="reference external" href="mailto:robertheinrich73@googlemail.com">robertheinrich73@googlemail.com</a>></li> +<li>simon <<a class="reference external" href="mailto:simon@banquise.net">simon@banquise.net</a>></li> +<li>Kelly Martin <<a class="reference external" href="mailto:kelly.lynn.martin@gmail.com">kelly.lynn.martin@gmail.com</a>></li> +<li>mizipzor <<a class="reference external" href="mailto:mizipzor@gmail.com">mizipzor@gmail.com</a>></li> +<li>Simon Jackson <<a class="reference external" href="mailto:sizeak@hotmail.com">sizeak@hotmail.com</a>></li> +<li>belal <<a class="reference external" href="mailto:jimbelal@gmail.com">jimbelal@gmail.com</a>></li> +<li>RusAnon <<a class="reference external" href="mailto:rusanon@dollchan.ru">rusanon@dollchan.ru</a>></li> +<li>Raoul XQ <<a class="reference external" href="mailto:raoulxq@gmail.com">raoulxq@gmail.com</a>></li> +<li>Matthew Cline <<a class="reference external" href="mailto:zelgadis@sourceforge.net">zelgadis@sourceforge.net</a>></li> +<li>Mike Stewart <<a class="reference external" href="mailto:thewonderidiot@gmail.com">thewonderidiot@gmail.com</a>></li> +<li>Timothy Collett <<a class="reference external" href="mailto:tcollett+github@topazgryphon.org">tcollett+github@topazgryphon.org</a>></li> +<li>RossM <<a class="reference external" href="mailto:Ross@Gnome">Ross@Gnome</a>></li> +<li>Tom Prince <<a class="reference external" href="mailto:tom.prince@ualberta.net">tom.prince@ualberta.net</a>></li> +<li>Jared Adams <<a class="reference external" href="mailto:jaxad0127@gmail.com">jaxad0127@gmail.com</a>></li> +<li>expwnent <<a class="reference external" href="mailto:q309185@gmail.com">q309185@gmail.com</a>></li> +<li>Erik Youngren <<a class="reference external" href="mailto:artanis.00@gmail.com">artanis.00@gmail.com</a>></li> +<li>Espen Wiborg <<a class="reference external" href="mailto:espen.wiborg@telio.no">espen.wiborg@telio.no</a>></li> +<li>Tim Walberg <<a class="reference external" href="mailto:twalberg@comcast.net">twalberg@comcast.net</a>></li> +<li>Mikko Juola <<a class="reference external" href="mailto:mikko.juola@kolumbus.fi">mikko.juola@kolumbus.fi</a>></li> +<li>rampaging-poet <<a class="reference external" href="mailto:yrudoingthis@hotmail.com">yrudoingthis@hotmail.com</a>></li> +<li>U-glouglou\simon</li> +<li>Clayton Hughes <<a class="reference external" href="mailto:clayton.hughes@gmail.com">clayton.hughes@gmail.com</a>></li> +<li>zilpin <<a class="reference external" href="mailto:ziLpin@gmail.com">ziLpin@gmail.com</a>></li> +<li>Will Rogers <<a class="reference external" href="mailto:wjrogers@gmail.com">wjrogers@gmail.com</a>></li> +<li>NMLittle <<a class="reference external" href="mailto:nmlittle@gmail.com">nmlittle@gmail.com</a>></li> +<li>root</li> +<li>reverb</li> +<li>Zhentar <<a class="reference external" href="mailto:Zhentar@gmail.com">Zhentar@gmail.com</a>></li> +<li>Valentin Ochs <<a class="reference external" href="mailto:a@0au.de">a@0au.de</a>></li> +<li>Priit Laes <<a class="reference external" href="mailto:plaes@plaes.org">plaes@plaes.org</a>></li> +<li>kmartin</li> +<li>Neil Little</li> +<li>rout <<a class="reference external" href="mailto:rout.mail+github@gmail.com">rout.mail+github@gmail.com</a>></li> +<li>rofl0r <<a class="reference external" href="mailto:retnyg@gmx.net">retnyg@gmx.net</a>></li> +<li>harlanplayford <<a class="reference external" href="mailto:harlanplayford@gmail.com">harlanplayford@gmail.com</a>></li> +<li>gsvslto <<a class="reference external" href="mailto:gsvslto@gmail.com">gsvslto@gmail.com</a>></li> +<li>sami</li> +<li>potato</li> +<li>playfordh <<a class="reference external" href="mailto:harlanplayford@gmail.com">harlanplayford@gmail.com</a>></li> +<li>feng1st <<a class="reference external" href="mailto:nf_xp@hotmail.com">nf_xp@hotmail.com</a>></li> +<li>comestible <<a class="reference external" href="mailto:nickolas.g.russell@gmail.com">nickolas.g.russell@gmail.com</a>></li> +<li>Rumrusher <<a class="reference external" href="mailto:Anuleakage@yahoo.com">Anuleakage@yahoo.com</a>></li> +<li>Rinin <<a class="reference external" href="mailto:RininS@Gmail.com">RininS@Gmail.com</a>></li> +<li>Raoul van Putten</li> +<li>John Shade <<a class="reference external" href="mailto:gsvslto@gmail.com">gsvslto@gmail.com</a>></li> +<li>John Beisley <<a class="reference external" href="mailto:greatred@gmail.com">greatred@gmail.com</a>></li> +<li>Feng <<a class="reference external" href="mailto:nf_xp@hotmail.com">nf_xp@hotmail.com</a>></li> +<li>Donald Ruegsegger <<a class="reference external" href="mailto:druegsegger@gmail.com">druegsegger@gmail.com</a>></li> +<li>Caldfir <<a class="reference external" href="mailto:caldfir@hotmail.com">caldfir@hotmail.com</a>></li> +<li>Antalia <<a class="reference external" href="mailto:tamarakorr@gmail.com">tamarakorr@gmail.com</a>></li> +<li>Angus Mezick <<a class="reference external" href="mailto:amezick@gmail.com">amezick@gmail.com</a>></li> +</ul> +</div> +</body> +</html> diff --git a/LUA Api.html b/LUA Api.html new file mode 100644 index 00000000..047ef978 --- /dev/null +++ b/LUA Api.html @@ -0,0 +1,2104 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="Docutils 0.9.1: http://docutils.sourceforge.net/" /> +<title>DFHack Lua API</title> +<style type="text/css"> + +/* +:Author: David Goodger (goodger@python.org) +:Id: $Id: html4css1.css 7434 2012-05-11 21:06:27Z milde $ +:Copyright: This stylesheet has been placed in the public domain. + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { + overflow: hidden; +} + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin: 0 0 0.5em 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left, .figure.align-left, object.align-left { + clear: left ; + float: left ; + margin-right: 1em } + +img.align-right, .figure.align-right, object.align-right { + clear: right ; + float: right ; + margin-left: 1em } + +img.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left } + +.align-center { + clear: both ; + text-align: center } + +.align-right { + text-align: right } + +/* reset inner alignment in figures */ +div.align-right { + text-align: inherit } + +/* div.align-center * { */ +/* text-align: left } */ + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font: inherit } + +pre.literal-block, pre.doctest-block, pre.math, pre.code { + margin-left: 2em ; + margin-right: 2em } + +pre.code .ln { /* line numbers */ + color: grey; +} + +.code { + background-color: #eeeeee +} + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } + +table.footnote { + border-left: solid 1px black; + margin-left: 1px } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +ul.auto-toc { + list-style-type: none } + +</style> +</head> +<body> +<div class="document" id="dfhack-lua-api"> +<h1 class="title">DFHack Lua API</h1> + +<div class="contents topic" id="contents"> +<p class="topic-title first">Contents</p> +<ul class="simple"> +<li><a class="reference internal" href="#df-data-structure-wrapper" id="id1">DF data structure wrapper</a><ul> +<li><a class="reference internal" href="#typed-object-references" id="id2">Typed object references</a><ul> +<li><a class="reference internal" href="#primitive-references" id="id3">Primitive references</a></li> +<li><a class="reference internal" href="#struct-references" id="id4">Struct references</a></li> +<li><a class="reference internal" href="#container-references" id="id5">Container references</a></li> +<li><a class="reference internal" href="#bitfield-references" id="id6">Bitfield references</a></li> +</ul> +</li> +<li><a class="reference internal" href="#named-types" id="id7">Named types</a></li> +<li><a class="reference internal" href="#global-functions" id="id8">Global functions</a></li> +<li><a class="reference internal" href="#recursive-table-assignment" id="id9">Recursive table assignment</a></li> +</ul> +</li> +<li><a class="reference internal" href="#dfhack-api" id="id10">DFHack API</a><ul> +<li><a class="reference internal" href="#native-utilities" id="id11">Native utilities</a><ul> +<li><a class="reference internal" href="#input-output" id="id12">Input & Output</a></li> +<li><a class="reference internal" href="#exception-handling" id="id13">Exception handling</a></li> +<li><a class="reference internal" href="#miscellaneous" id="id14">Miscellaneous</a></li> +<li><a class="reference internal" href="#locking-and-finalization" id="id15">Locking and finalization</a></li> +<li><a class="reference internal" href="#persistent-configuration-storage" id="id16">Persistent configuration storage</a></li> +<li><a class="reference internal" href="#material-info-lookup" id="id17">Material info lookup</a></li> +</ul> +</li> +<li><a class="reference internal" href="#c-function-wrappers" id="id18">C++ function wrappers</a><ul> +<li><a class="reference internal" href="#gui-module" id="id19">Gui module</a></li> +<li><a class="reference internal" href="#job-module" id="id20">Job module</a></li> +<li><a class="reference internal" href="#units-module" id="id21">Units module</a></li> +<li><a class="reference internal" href="#items-module" id="id22">Items module</a></li> +<li><a class="reference internal" href="#maps-module" id="id23">Maps module</a></li> +<li><a class="reference internal" href="#burrows-module" id="id24">Burrows module</a></li> +<li><a class="reference internal" href="#buildings-module" id="id25">Buildings module</a></li> +<li><a class="reference internal" href="#constructions-module" id="id26">Constructions module</a></li> +<li><a class="reference internal" href="#screen-api" id="id27">Screen API</a></li> +<li><a class="reference internal" href="#internal-api" id="id28">Internal API</a></li> +</ul> +</li> +<li><a class="reference internal" href="#core-interpreter-context" id="id29">Core interpreter context</a><ul> +<li><a class="reference internal" href="#event-type" id="id30">Event type</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#lua-modules" id="id31">Lua Modules</a><ul> +<li><a class="reference internal" href="#global-environment" id="id32">Global environment</a></li> +<li><a class="reference internal" href="#utils" id="id33">utils</a></li> +<li><a class="reference internal" href="#dumper" id="id34">dumper</a></li> +<li><a class="reference internal" href="#class" id="id35">class</a></li> +</ul> +</li> +<li><a class="reference internal" href="#plugins" id="id36">Plugins</a><ul> +<li><a class="reference internal" href="#burrows" id="id37">burrows</a></li> +<li><a class="reference internal" href="#sort" id="id38">sort</a></li> +</ul> +</li> +<li><a class="reference internal" href="#scripts" id="id39">Scripts</a></li> +</ul> +</div> +<p>The current version of DFHack has extensive support for +the Lua scripting language, providing access to:</p> +<ol class="arabic simple"> +<li>Raw data structures used by the game.</li> +<li>Many C++ functions for high-level access to these +structures, and interaction with dfhack itself.</li> +<li>Some functions exported by C++ plugins.</li> +</ol> +<p>Lua code can be used both for writing scripts, which +are treated by DFHack command line prompt almost as +native C++ commands, and invoked by plugins written in c++.</p> +<p>This document describes native API available to Lua in detail. +It does not describe all of the utility functions +implemented by Lua files located in hack/lua/...</p> +<div class="section" id="df-data-structure-wrapper"> +<h1><a class="toc-backref" href="#id1">DF data structure wrapper</a></h1> +<p>DF structures described by the xml files in library/xml are exported +to lua code as a tree of objects and functions under the <tt class="docutils literal">df</tt> global, +which broadly maps to the <tt class="docutils literal">df</tt> namespace in C++.</p> +<p><strong>WARNING</strong>: The wrapper provides almost raw access to the memory +of the game, so mistakes in manipulating objects are as likely to +crash the game as equivalent plain C++ code would be. E.g. NULL +pointer access is safely detected, but dangling pointers aren't.</p> +<p>Objects managed by the wrapper can be broadly classified into the following groups:</p> +<ol class="arabic"> +<li><p class="first">Typed object pointers (references).</p> +<p>References represent objects in DF memory with a known type.</p> +<p>In addition to fields and methods defined by the wrapped type, +every reference has some built-in properties and methods.</p> +</li> +<li><p class="first">Untyped pointers</p> +<p>Represented as lightuserdata.</p> +<p>In assignment to a pointer NULL can be represented either as +<tt class="docutils literal">nil</tt>, or a NULL lightuserdata; reading a NULL pointer field +returns <tt class="docutils literal">nil</tt>.</p> +</li> +<li><p class="first">Named types</p> +<p>Objects in the <tt class="docutils literal">df</tt> tree that represent identity of struct, class, +enum and bitfield types. They host nested named types, static +methods, builtin properties & methods, and, for enums and bitfields, +the bi-directional mapping between key names and values.</p> +</li> +<li><p class="first">The <tt class="docutils literal">global</tt> object</p> +<p><tt class="docutils literal">df.global</tt> corresponds to the <tt class="docutils literal"><span class="pre">df::global</span></tt> namespace, and +behaves as a mix between a named type and a reference, containing +both nested types and fields corresponding to global symbols.</p> +</li> +</ol> +<p>In addition to the <tt class="docutils literal">global</tt> object and top-level types the <tt class="docutils literal">df</tt> +global also contains a few global builtin utility functions.</p> +<div class="section" id="typed-object-references"> +<h2><a class="toc-backref" href="#id2">Typed object references</a></h2> +<p>The underlying primitive lua object is userdata with a metatable. +Every structured field access produces a new userdata instance.</p> +<p>All typed objects have the following built-in features:</p> +<ul> +<li><p class="first"><tt class="docutils literal">ref1 == ref2</tt>, <tt class="docutils literal">tostring(ref)</tt></p> +<p>References implement equality by type & pointer value, and string conversion.</p> +</li> +<li><p class="first"><tt class="docutils literal">pairs(ref)</tt></p> +<p>Returns an iterator for the sequence of actual C++ field names +and values. Fields are enumerated in memory order. Methods and +lua wrapper properties are not included in the iteration.</p> +<p><strong>WARNING</strong>: a few of the data structures (like ui_look_list) +contain unions with pointers to different types with vtables. +Using pairs on such structs is an almost sure way to crash with +an access violation.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref._kind</tt></p> +<p>Returns one of: <tt class="docutils literal">primitive</tt>, <tt class="docutils literal">struct</tt>, <tt class="docutils literal">container</tt>, +or <tt class="docutils literal">bitfield</tt>, as appropriate for the referenced object.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref._type</tt></p> +<p>Returns the named type object or a string that represents +the referenced object type.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref:sizeof()</tt></p> +<p>Returns <em>size, address</em></p> +</li> +<li><p class="first"><tt class="docutils literal">ref:new()</tt></p> +<p>Allocates a new instance of the same type, and copies data +from the current object.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref:delete()</tt></p> +<p>Destroys the object with the C++ <tt class="docutils literal">delete</tt> operator. +If destructor is not available, returns <em>false</em>.</p> +<p><strong>WARNING</strong>: the lua reference object remains as a dangling +pointer, like a raw C++ pointer would.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref:assign(object)</tt></p> +<p>Assigns data from object to ref. Object must either be another +ref of a compatible type, or a lua table; in the latter case +special recursive assignment rules are applied.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">ref:_displace(index[,step])</span></tt></p> +<p>Returns a new reference with the pointer adjusted by index*step. +Step defaults to the natural object size.</p> +</li> +</ul> +<div class="section" id="primitive-references"> +<h3><a class="toc-backref" href="#id3">Primitive references</a></h3> +<p>References of the <em>_kind</em> <tt class="docutils literal">'primitive'</tt> are used for objects +that don't fit any of the other reference types. Such +references can only appear as a value of a pointer field, +or as a result of calling the <tt class="docutils literal">_field()</tt> method.</p> +<p>They behave as structs with one field <tt class="docutils literal">value</tt> of the right type.</p> +<p>To make working with numeric buffers easier, they also allow +numeric indices. Note that other than excluding negative values +no bound checking is performed, since buffer length is not available. +Index 0 is equivalent to the <tt class="docutils literal">value</tt> field.</p> +</div> +<div class="section" id="struct-references"> +<h3><a class="toc-backref" href="#id4">Struct references</a></h3> +<p>Struct references are used for class and struct objects.</p> +<p>They implement the following features:</p> +<ul> +<li><p class="first"><tt class="docutils literal">ref.field</tt>, <tt class="docutils literal">ref.field = value</tt></p> +<p>Valid fields of the structure may be accessed by subscript.</p> +<p>Primitive typed fields, i.e. numbers & strings, are converted +to/from matching lua values. The value of a pointer is a reference +to the target, or nil/NULL. Complex types are represented by +a reference to the field within the structure; unless recursive +lua table assignment is used, such fields can only be read.</p> +<p><strong>NOTE:</strong> In case of inheritance, <em>superclass</em> fields have precedence +over the subclass, but fields shadowed in this way can still +be accessed as <tt class="docutils literal"><span class="pre">ref['subclasstype.field']</span></tt>. +This shadowing order is necessary because vtable-based classes +are automatically exposed in their exact type, and the reverse +rule would make access to superclass fields unreliable.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref._field(field)</tt></p> +<p>Returns a reference to a valid field. That is, unlike regular +subscript, it returns a reference to the field within the structure +even for primitive typed fields and pointers.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">ref:vmethod(args...)</span></tt></p> +<p>Named virtual methods are also exposed, subject to the same +shadowing rules.</p> +</li> +<li><p class="first"><tt class="docutils literal">pairs(ref)</tt></p> +<p>Enumerates all real fields (but not methods) in memory +(= declaration) order.</p> +</li> +</ul> +</div> +<div class="section" id="container-references"> +<h3><a class="toc-backref" href="#id5">Container references</a></h3> +<p>Containers represent vectors and arrays, possibly resizable.</p> +<p>A container field can associate an enum to the container +reference, which allows accessing elements using string keys +instead of numerical indices.</p> +<p>Implemented features:</p> +<ul> +<li><p class="first"><tt class="docutils literal">ref._enum</tt></p> +<p>If the container has an associated enum, returns the matching +named type object.</p> +</li> +<li><p class="first"><tt class="docutils literal">#ref</tt></p> +<p>Returns the <em>length</em> of the container.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref[index]</tt></p> +<p>Accesses the container element, using either a <em>0-based</em> numerical +index, or, if an enum is associated, a valid enum key string.</p> +<p>Accessing an invalid index is an error, but some container types +may return a default value, or auto-resize instead for convenience. +Currently this relaxed mode is implemented by df-flagarray aka BitArray.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref._field(index)</tt></p> +<p>Like with structs, returns a pointer to the array element, if possible. +Flag and bit arrays cannot return such pointer, so it fails with an error.</p> +</li> +<li><p class="first"><tt class="docutils literal">pairs(ref)</tt>, <tt class="docutils literal">ipairs(ref)</tt></p> +<p>If the container has no associated enum, both behave identically, +iterating over numerical indices in order. Otherwise, ipairs still +uses numbers, while pairs tries to substitute enum keys whenever +possible.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref:resize(new_size)</tt></p> +<p>Resizes the container if supported, or fails with an error.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref:insert(index,item)</tt></p> +<p>Inserts a new item at the specified index. To add at the end, +use <tt class="docutils literal">#ref</tt>, or just <tt class="docutils literal">'#'</tt> as index.</p> +</li> +<li><p class="first"><tt class="docutils literal">ref:erase(index)</tt></p> +<p>Removes the element at the given valid index.</p> +</li> +</ul> +</div> +<div class="section" id="bitfield-references"> +<h3><a class="toc-backref" href="#id6">Bitfield references</a></h3> +<p>Bitfields behave like special fixed-size containers. +Consider them to be something in between structs and +fixed-size vectors.</p> +<p>The <tt class="docutils literal">_enum</tt> property points to the bitfield type. +Numerical indices correspond to the shift value, +and if a subfield occupies multiple bits, the +<tt class="docutils literal">ipairs</tt> order would have a gap.</p> +<p>Since currently there is no API to allocate a bitfield +object fully in GC-managed lua heap, consider using the +lua table assignment feature outlined below in order to +pass bitfield values to dfhack API functions that need +them, e.g. <tt class="docutils literal">matinfo:matches{metal=true}</tt>.</p> +</div> +</div> +<div class="section" id="named-types"> +<h2><a class="toc-backref" href="#id7">Named types</a></h2> +<p>Named types are exposed in the <tt class="docutils literal">df</tt> tree with names identical +to the C++ version, except for the <tt class="docutils literal">::</tt> vs <tt class="docutils literal">.</tt> difference.</p> +<p>All types and the global object have the following features:</p> +<ul> +<li><p class="first"><tt class="docutils literal">type._kind</tt></p> +<p>Evaluates to one of <tt class="docutils literal"><span class="pre">struct-type</span></tt>, <tt class="docutils literal"><span class="pre">class-type</span></tt>, <tt class="docutils literal"><span class="pre">enum-type</span></tt>, +<tt class="docutils literal"><span class="pre">bitfield-type</span></tt> or <tt class="docutils literal">global</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">type._identity</tt></p> +<p>Contains a lightuserdata pointing to the underlying +DFHack::type_instance object.</p> +</li> +</ul> +<p>Types excluding the global object also support:</p> +<ul> +<li><p class="first"><tt class="docutils literal">type:sizeof()</tt></p> +<p>Returns the size of an object of the type.</p> +</li> +<li><p class="first"><tt class="docutils literal">type:new()</tt></p> +<p>Creates a new instance of an object of the type.</p> +</li> +<li><p class="first"><tt class="docutils literal">type:is_instance(object)</tt></p> +<p>Returns true if object is same or subclass type, or a reference +to an object of same or subclass type. It is permissible to pass +nil, NULL or non-wrapper value as object; in this case the +method returns nil.</p> +</li> +</ul> +<p>In addition to this, enum and bitfield types contain a +bi-directional mapping between key strings and values, and +also map <tt class="docutils literal">_first_item</tt> and <tt class="docutils literal">_last_item</tt> to the min and +max values.</p> +<p>Struct and class types with instance-vector attribute in the +xml have a <tt class="docutils literal">type.find(key)</tt> function that wraps the find +method provided in C++.</p> +</div> +<div class="section" id="global-functions"> +<h2><a class="toc-backref" href="#id8">Global functions</a></h2> +<p>The <tt class="docutils literal">df</tt> table itself contains the following functions and values:</p> +<ul> +<li><p class="first"><tt class="docutils literal">NULL</tt>, <tt class="docutils literal">df.NULL</tt></p> +<p>Contains the NULL lightuserdata.</p> +</li> +<li><p class="first"><tt class="docutils literal">df.isnull(obj)</tt></p> +<p>Evaluates to true if obj is nil or NULL; false otherwise.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">df.isvalid(obj[,allow_null])</span></tt></p> +<p>For supported objects returns one of <tt class="docutils literal">type</tt>, <tt class="docutils literal">voidptr</tt>, <tt class="docutils literal">ref</tt>.</p> +<p>If <em>allow_null</em> is true, and obj is nil or NULL, returns <tt class="docutils literal">null</tt>.</p> +<p>Otherwise returns <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">df.sizeof(obj)</tt></p> +<p>For types and refs identical to <tt class="docutils literal">obj:sizeof()</tt>. +For lightuserdata returns <em>nil, address</em></p> +</li> +<li><p class="first"><tt class="docutils literal">df.new(obj)</tt>, <tt class="docutils literal">df.delete(obj)</tt>, <tt class="docutils literal">df.assign(obj, obj2)</tt></p> +<p>Equivalent to using the matching methods of obj.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">df._displace(obj,index[,step])</span></tt></p> +<p>For refs equivalent to the method, but also works with +lightuserdata (step is mandatory then).</p> +</li> +<li><p class="first"><tt class="docutils literal">df.is_instance(type,obj)</tt></p> +<p>Equivalent to the method, but also allows a reference as proxy for its type.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">df.new(ptype[,count])</span></tt></p> +<p>Allocate a new instance, or an array of built-in types. +The <tt class="docutils literal">ptype</tt> argument is a string from the following list: +<tt class="docutils literal">string</tt>, <tt class="docutils literal">int8_t</tt>, <tt class="docutils literal">uint8_t</tt>, <tt class="docutils literal">int16_t</tt>, <tt class="docutils literal">uint16_t</tt>, +<tt class="docutils literal">int32_t</tt>, <tt class="docutils literal">uint32_t</tt>, <tt class="docutils literal">int64_t</tt>, <tt class="docutils literal">uint64_t</tt>, <tt class="docutils literal">bool</tt>, +<tt class="docutils literal">float</tt>, <tt class="docutils literal">double</tt>. All of these except <tt class="docutils literal">string</tt> can be +used with the count argument to allocate an array.</p> +</li> +<li><p class="first"><tt class="docutils literal">df.reinterpret_cast(type,ptr)</tt></p> +<p>Converts ptr to a ref of specified type. The type may be anything +acceptable to <tt class="docutils literal">df.is_instance</tt>. Ptr may be <em>nil</em>, a ref, +a lightuserdata, or a number.</p> +<p>Returns <em>nil</em> if NULL, or a ref.</p> +</li> +</ul> +</div> +<div class="section" id="recursive-table-assignment"> +<h2><a class="toc-backref" href="#id9">Recursive table assignment</a></h2> +<p>Recursive assignment is invoked when a lua table is assigned +to a C++ object or field, i.e. one of:</p> +<ul class="simple"> +<li><tt class="docutils literal"><span class="pre">ref:assign{...}</span></tt></li> +<li><tt class="docutils literal">ref.field = <span class="pre">{...}</span></tt></li> +</ul> +<p>The general mode of operation is that all fields of the table +are assigned to the fields of the target structure, roughly +emulating the following code:</p> +<pre class="literal-block"> +function rec_assign(ref,table) + for key,value in pairs(table) do + ref[key] = value + end +end +</pre> +<p>Since assigning a table to a field using = invokes the same +process, it is recursive.</p> +<p>There are however some variations to this process depending +on the type of the field being assigned to:</p> +<ol class="arabic"> +<li><p class="first">If the table contains an <tt class="docutils literal">assign</tt> field, it is +applied first, using the <tt class="docutils literal">ref:assign(value)</tt> method. +It is never assigned as a usual field.</p> +</li> +<li><p class="first">When a table is assigned to a non-NULL pointer field +using the <tt class="docutils literal">ref.field = <span class="pre">{...}</span></tt> syntax, it is applied +to the target of the pointer instead.</p> +<p>If the pointer is NULL, the table is checked for a <tt class="docutils literal">new</tt> field:</p> +<ol class="loweralpha simple"> +<li>If it is <em>nil</em> or <em>false</em>, assignment fails with an error.</li> +<li>If it is <em>true</em>, the pointer is initialized with a newly +allocated object of the declared target type of the pointer.</li> +<li>Otherwise, <tt class="docutils literal">table.new</tt> must be a named type, or an +object of a type compatible with the pointer. The pointer +is initialized with the result of calling <tt class="docutils literal">table.new:new()</tt>.</li> +</ol> +<p>After this auto-vivification process, assignment proceeds +as if the pointer wasn't NULL.</p> +<p>Obviously, the <tt class="docutils literal">new</tt> field inside the table is always skipped +during the actual per-field assignment processing.</p> +</li> +<li><p class="first">If the target of the assignment is a container, a separate +rule set is used:</p> +<ol class="loweralpha"> +<li><p class="first">If the table contains neither <tt class="docutils literal">assign</tt> nor <tt class="docutils literal">resize</tt> +fields, it is interpreted as an ordinary <em>1-based</em> lua +array. The container is resized to the #-size of the +table, and elements are assigned in numeric order:</p> +<pre class="literal-block"> +ref:resize(#table); +for i=1,#table do ref[i-1] = table[i] end +</pre> +</li> +<li><p class="first">Otherwise, <tt class="docutils literal">resize</tt> must be <em>true</em>, <em>false</em>, or +an explicit number. If it is not false, the container +is resized. After that the usual struct-like 'pairs' +assignment is performed.</p> +<p>In case <tt class="docutils literal">resize</tt> is <em>true</em>, the size is computed +by scanning the table for the largest numeric key.</p> +</li> +</ol> +<p>This means that in order to reassign only one element of +a container using this system, it is necessary to use:</p> +<pre class="literal-block"> +{ resize=false, [idx]=value } +</pre> +</li> +</ol> +<p>Since nil inside a table is indistinguishable from missing key, +it is necessary to use <tt class="docutils literal">df.NULL</tt> as a null pointer value.</p> +<p>This system is intended as a way to define a nested object +tree using pure lua data structures, and then materialize it in +C++ memory in one go. Note that if pointer auto-vivification +is used, an error in the middle of the recursive walk would +not destroy any objects allocated in this way, so the user +should be prepared to catch the error and do the necessary +cleanup.</p> +</div> +</div> +<div class="section" id="dfhack-api"> +<h1><a class="toc-backref" href="#id10">DFHack API</a></h1> +<p>DFHack utility functions are placed in the <tt class="docutils literal">dfhack</tt> global tree.</p> +<div class="section" id="native-utilities"> +<h2><a class="toc-backref" href="#id11">Native utilities</a></h2> +<div class="section" id="input-output"> +<h3><a class="toc-backref" href="#id12">Input & Output</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.print(args...)</span></tt></p> +<p>Output tab-separated args as standard lua print would do, +but without a newline.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">print(args...)</span></tt>, <tt class="docutils literal"><span class="pre">dfhack.println(args...)</span></tt></p> +<p>A replacement of the standard library print function that +works with DFHack output infrastructure.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.printerr(args...)</span></tt></p> +<p>Same as println; intended for errors. Uses red color and logs to stderr.log.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.color([color])</span></tt></p> +<p>Sets the current output color. If color is <em>nil</em> or <em>-1</em>, resets to default. +Returns the previous color value.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.is_interactive()</tt></p> +<p>Checks if the thread can access the interactive console and returns <em>true</em> or <em>false</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.lineedit([prompt[,history_filename]])</span></tt></p> +<p>If the thread owns the interactive console, shows a prompt +and returns the entered string. Otherwise returns <em>nil, error</em>.</p> +<p>Depending on the context, this function may actually yield the +running coroutine and let the C++ code release the core suspend +lock. Using an explicit <tt class="docutils literal">dfhack.with_suspend</tt> will prevent +this, forcing the function to block on input with lock held.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.interpreter([prompt[,history_filename[,env]]])</span></tt></p> +<p>Starts an interactive lua interpreter, using the specified prompt +string, global environment and command-line history file.</p> +<p>If the interactive console is not accessible, returns <em>nil, error</em>.</p> +</li> +</ul> +</div> +<div class="section" id="exception-handling"> +<h3><a class="toc-backref" href="#id13">Exception handling</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.error(msg[,level[,verbose]])</span></tt></p> +<p>Throws a dfhack exception object with location and stack trace. +The verbose parameter controls whether the trace is printed by default.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">qerror(msg[,level])</span></tt></p> +<p>Calls <tt class="docutils literal">dfhack.error()</tt> with <tt class="docutils literal">verbose</tt> being <em>false</em>. Intended to +be used for user-caused errors in scripts, where stack traces are not +desirable.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.pcall(f[,args...])</span></tt></p> +<p>Invokes f via xpcall, using an error function that attaches +a stack trace to the error. The same function is used by SafeCall +in C++, and dfhack.safecall.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">safecall(f[,args...])</span></tt>, <tt class="docutils literal"><span class="pre">dfhack.safecall(f[,args...])</span></tt></p> +<p>Just like pcall, but also prints the error using printerr before +returning. Intended as a convenience function.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.saferesume(coroutine[,args...])</span></tt></p> +<p>Compares to coroutine.resume like dfhack.safecall vs pcall.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.exception</tt></p> +<p>Metatable of error objects used by dfhack. The objects have the +following properties:</p> +<dl class="docutils"> +<dt><tt class="docutils literal">err.where</tt></dt> +<dd><p class="first last">The location prefix string, or <em>nil</em>.</p> +</dd> +<dt><tt class="docutils literal">err.message</tt></dt> +<dd><p class="first last">The base message string.</p> +</dd> +<dt><tt class="docutils literal">err.stacktrace</tt></dt> +<dd><p class="first last">The stack trace string, or <em>nil</em>.</p> +</dd> +<dt><tt class="docutils literal">err.cause</tt></dt> +<dd><p class="first last">A different exception object, or <em>nil</em>.</p> +</dd> +<dt><tt class="docutils literal">err.thread</tt></dt> +<dd><p class="first last">The coroutine that has thrown the exception.</p> +</dd> +<dt><tt class="docutils literal">err.verbose</tt></dt> +<dd><p class="first last">Boolean, or <em>nil</em>; specifies if where and stacktrace should be printed.</p> +</dd> +<dt><tt class="docutils literal">tostring(err)</tt>, or <tt class="docutils literal"><span class="pre">err:tostring([verbose])</span></tt></dt> +<dd><p class="first last">Converts the exception to string.</p> +</dd> +</dl> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.exception.verbose</tt></p> +<p>The default value of the <tt class="docutils literal">verbose</tt> argument of <tt class="docutils literal">err:tostring()</tt>.</p> +</li> +</ul> +</div> +<div class="section" id="miscellaneous"> +<h3><a class="toc-backref" href="#id14">Miscellaneous</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.VERSION</tt></p> +<p>DFHack version string constant.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.curry(func,args...)</span></tt>, or <tt class="docutils literal"><span class="pre">curry(func,args...)</span></tt></p> +<p>Returns a closure that invokes the function with args combined +both from the curry call and the closure call itself. I.e. +<tt class="docutils literal"><span class="pre">curry(func,a,b)(c,d)</span></tt> equals <tt class="docutils literal">func(a,b,c,d)</tt>.</p> +</li> +</ul> +</div> +<div class="section" id="locking-and-finalization"> +<h3><a class="toc-backref" href="#id15">Locking and finalization</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.with_suspend(f[,args...])</span></tt></p> +<p>Calls <tt class="docutils literal">f</tt> with arguments after grabbing the DF core suspend lock. +Suspending is necessary for accessing a consistent state of DF memory.</p> +<p>Returned values and errors are propagated through after releasing +the lock. It is safe to nest suspends.</p> +<p>Every thread is allowed only one suspend per DF frame, so it is best +to group operations together in one big critical section. A plugin +can choose to run all lua code inside a C++-side suspend lock.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.call_with_finalizer(num_cleanup_args,always,cleanup_fn[,cleanup_args...],fn[,args...])</span></tt></p> +<p>Invokes <tt class="docutils literal">fn</tt> with <tt class="docutils literal">args</tt>, and after it returns or throws an +error calls <tt class="docutils literal">cleanup_fn</tt> with <tt class="docutils literal">cleanup_args</tt>. Any return values from +<tt class="docutils literal">fn</tt> are propagated, and errors are re-thrown.</p> +<p>The <tt class="docutils literal">num_cleanup_args</tt> integer specifies the number of <tt class="docutils literal">cleanup_args</tt>, +and the <tt class="docutils literal">always</tt> boolean specifies if cleanup should be called in any case, +or only in case of an error.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.with_finalize(cleanup_fn,fn[,args...])</span></tt></p> +<p>Calls <tt class="docutils literal">fn</tt> with arguments, then finalizes with <tt class="docutils literal">cleanup_fn</tt>. +Implemented using <tt class="docutils literal"><span class="pre">call_with_finalizer(0,true,...)</span></tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.with_onerror(cleanup_fn,fn[,args...])</span></tt></p> +<p>Calls <tt class="docutils literal">fn</tt> with arguments, then finalizes with <tt class="docutils literal">cleanup_fn</tt> on any thrown error. +Implemented using <tt class="docutils literal"><span class="pre">call_with_finalizer(0,false,...)</span></tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.with_temp_object(obj,fn[,args...])</span></tt></p> +<p>Calls <tt class="docutils literal"><span class="pre">fn(obj,args...)</span></tt>, then finalizes with <tt class="docutils literal">obj:delete()</tt>.</p> +</li> +</ul> +</div> +<div class="section" id="persistent-configuration-storage"> +<h3><a class="toc-backref" href="#id16">Persistent configuration storage</a></h3> +<p>This api is intended for storing configuration options in the world itself. +It probably should be restricted to data that is world-dependent.</p> +<p>Entries are identified by a string <tt class="docutils literal">key</tt>, but it is also possible to manage +multiple entries with the same key; their identity is determined by <tt class="docutils literal">entry_id</tt>. +Every entry has a mutable string <tt class="docutils literal">value</tt>, and an array of 7 mutable <tt class="docutils literal">ints</tt>.</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.persistent.get(key)</tt>, <tt class="docutils literal">entry:get()</tt></p> +<p>Retrieves a persistent config record with the given string key, +or refreshes an already retrieved entry. If there are multiple +entries with the same key, it is undefined which one is retrieved +by the first version of the call.</p> +<p>Returns entry, or <em>nil</em> if not found.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.persistent.delete(key)</tt>, <tt class="docutils literal">entry:delete()</tt></p> +<p>Removes an existing entry. Returns <em>true</em> if succeeded.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.persistent.get_all(key[,match_prefix])</span></tt></p> +<p>Retrieves all entries with the same key, or starting with key..'/'. +Calling <tt class="docutils literal"><span class="pre">get_all('',true)</span></tt> will match all entries.</p> +<p>If none found, returns nil; otherwise returns an array of entries.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.persistent.save({key=str1,</span> <span class="pre">...}[,new])</span></tt>, <tt class="docutils literal"><span class="pre">entry:save([new])</span></tt></p> +<p>Saves changes in an entry, or creates a new one. Passing true as +new forces creation of a new entry even if one already exists; +otherwise the existing one is simply updated. +Returns <em>entry, did_create_new</em></p> +</li> +</ul> +<p>Since the data is hidden in data structures owned by the DF world, +and automatically stored in the save game, these save and retrieval +functions can just copy values in memory without doing any actual I/O. +However, currently every entry has a 180+-byte dead-weight overhead.</p> +</div> +<div class="section" id="material-info-lookup"> +<h3><a class="toc-backref" href="#id17">Material info lookup</a></h3> +<p>A material info record has fields:</p> +<ul> +<li><p class="first"><tt class="docutils literal">type</tt>, <tt class="docutils literal">index</tt>, <tt class="docutils literal">material</tt></p> +<p>DF material code pair, and a reference to the material object.</p> +</li> +<li><p class="first"><tt class="docutils literal">mode</tt></p> +<p>One of <tt class="docutils literal">'builtin'</tt>, <tt class="docutils literal">'inorganic'</tt>, <tt class="docutils literal">'plant'</tt>, <tt class="docutils literal">'creature'</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">inorganic</tt>, <tt class="docutils literal">plant</tt>, <tt class="docutils literal">creature</tt></p> +<p>If the material is of the matching type, contains a reference to the raw object.</p> +</li> +<li><p class="first"><tt class="docutils literal">figure</tt></p> +<p>For a specific creature material contains a ref to the historical figure.</p> +</li> +</ul> +<p>Functions:</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.matinfo.decode(type,index)</tt></p> +<p>Looks up material info for the given number pair; if not found, returs <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">....decode(matinfo)</span></tt>, <tt class="docutils literal"><span class="pre">....decode(item)</span></tt>, <tt class="docutils literal"><span class="pre">....decode(obj)</span></tt></p> +<p>Uses <tt class="docutils literal">matinfo.type</tt>/<tt class="docutils literal">matinfo.index</tt>, item getter vmethods, +or <tt class="docutils literal">obj.mat_type</tt>/<tt class="docutils literal">obj.mat_index</tt> to get the code pair.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.matinfo.find(token[,token...])</span></tt></p> +<p>Looks up material by a token string, or a pre-split string token sequence.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.matinfo.getToken(...)</span></tt>, <tt class="docutils literal">info:getToken()</tt></p> +<p>Applies <tt class="docutils literal">decode</tt> and constructs a string token.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">info:toString([temperature[,named]])</span></tt></p> +<p>Returns the human-readable name at the given temperature.</p> +</li> +<li><p class="first"><tt class="docutils literal">info:getCraftClass()</tt></p> +<p>Returns the classification used for craft skills.</p> +</li> +<li><p class="first"><tt class="docutils literal">info:matches(obj)</tt></p> +<p>Checks if the material matches job_material_category or job_item. +Accept dfhack_material_category auto-assign table.</p> +</li> +</ul> +</div> +</div> +<div class="section" id="c-function-wrappers"> +<h2><a class="toc-backref" href="#id18">C++ function wrappers</a></h2> +<p>Thin wrappers around C++ functions, similar to the ones for virtual methods. +One notable difference is that these explicit wrappers allow argument count +adjustment according to the usual lua rules, so trailing false/nil arguments +can be omitted.</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.getOSType()</tt></p> +<p>Returns the OS type string from <tt class="docutils literal">symbols.xml</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.getDFVersion()</tt></p> +<p>Returns the DF version string from <tt class="docutils literal">symbols.xml</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.getDFPath()</tt></p> +<p>Returns the DF directory path.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.getHackPath()</tt></p> +<p>Returns the dfhack directory path, i.e. <tt class="docutils literal"><span class="pre">".../df/hack/"</span></tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.getTickCount()</tt></p> +<p>Returns the tick count in ms, exactly as DF ui uses.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.isWorldLoaded()</tt></p> +<p>Checks if the world is loaded.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.isMapLoaded()</tt></p> +<p>Checks if the world and map are loaded.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.TranslateName(name[,in_english,only_last_name])</span></tt></p> +<p>Convert a language_name or only the last name part to string.</p> +</li> +</ul> +<div class="section" id="gui-module"> +<h3><a class="toc-backref" href="#id19">Gui module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.getCurViewscreen([skip_dismissed])</span></tt></p> +<p>Returns the topmost viewscreen. If <tt class="docutils literal">skip_dismissed</tt> is <em>true</em>, +ignores screens already marked to be removed.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.gui.getFocusString(viewscreen)</tt></p> +<p>Returns a string representation of the current focus position +in the ui. The string has a "screen/foo/bar/baz..." format.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.getCurFocus([skip_dismissed])</span></tt></p> +<p>Returns the focus string of the current viewscreen.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.getSelectedWorkshopJob([silent])</span></tt></p> +<p>When a job is selected in <em>'q'</em> mode, returns the job, else +prints error unless silent and returns <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.getSelectedJob([silent])</span></tt></p> +<p>Returns the job selected in a workshop or unit/jobs screen.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.getSelectedUnit([silent])</span></tt></p> +<p>Returns the unit selected via <em>'v'</em>, <em>'k'</em>, unit/jobs, or +a full-screen item view of a cage or suchlike.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.getSelectedItem([silent])</span></tt></p> +<p>Returns the item selected via <em>'v'</em> ->inventory, <em>'k'</em>, <em>'t'</em>, or +a full-screen item view of a container. Note that in the +last case, the highlighted <em>contained item</em> is returned, not +the container itself.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.getSelectedBuilding([silent])</span></tt></p> +<p>Returns the building selected via <em>'q'</em>, <em>'t'</em>, <em>'k'</em> or <em>'i'</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.showAnnouncement(text,color[,is_bright])</span></tt></p> +<p>Adds a regular announcement with given text, color, and brightness. +The is_bright boolean actually seems to invert the brightness.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.showZoomAnnouncement(type,pos,text,color[,is_bright])</span></tt></p> +<p>Like above, but also specifies a position you can zoom to from the announcement menu.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.showPopupAnnouncement(text,color[,is_bright])</span></tt></p> +<p>Pops up a titan-style modal announcement window.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.gui.showAutoAnnouncement(type,pos,text,color[,is_bright])</span></tt></p> +<p>Uses the type to look up options from announcements.txt, and calls the +above operations accordingly. If enabled, pauses and zooms to position.</p> +</li> +</ul> +</div> +<div class="section" id="job-module"> +<h3><a class="toc-backref" href="#id20">Job module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.job.cloneJobStruct(job)</tt></p> +<p>Creates a deep copy of the given job.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.printJobDetails(job)</tt></p> +<p>Prints info about the job.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.printItemDetails(jobitem,idx)</tt></p> +<p>Prints info about the job item.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.getHolder(job)</tt></p> +<p>Returns the building holding the job.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.getWorker(job)</tt></p> +<p>Returns the unit performing the job.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.checkBuildingsNow()</tt></p> +<p>Instructs the game to check buildings for jobs next frame and assign workers.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.checkDesignationsNow()</tt></p> +<p>Instructs the game to check designations for jobs next frame and assign workers.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.is_equal(job1,job2)</tt></p> +<p>Compares important fields in the job and nested item structures.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.is_item_equal(job_item1,job_item2)</tt></p> +<p>Compares important fields in the job item structures.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.job.listNewlyCreated(first_id)</tt></p> +<p>Returns the current value of <tt class="docutils literal">df.global.job_next_id</tt>, and +if there are any jobs with <tt class="docutils literal">first_id <= id < job_next_id</tt>, +a lua list containing them.</p> +</li> +</ul> +</div> +<div class="section" id="units-module"> +<h3><a class="toc-backref" href="#id21">Units module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.units.getPosition(unit)</tt></p> +<p>Returns true <em>x,y,z</em> of the unit, or <em>nil</em> if invalid; may be not equal to unit.pos if caged.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getContainer(unit)</tt></p> +<p>Returns the container (cage) item or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.setNickname(unit,nick)</tt></p> +<p>Sets the unit's nickname properly.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getVisibleName(unit)</tt></p> +<p>Returns the language_name object visible in game, accounting for false identities.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getIdentity(unit)</tt></p> +<p>Returns the false identity of the unit if it has one, or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getNemesis(unit)</tt></p> +<p>Returns the nemesis record of the unit if it has one, or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isHidingCurse(unit)</tt></p> +<p>Checks if the unit hides improved attributes from its curse.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getPhysicalAttrValue(unit, attr_type)</tt></p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getMentalAttrValue(unit, attr_type)</tt></p> +<p>Computes the effective attribute value, including curse effect.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isCrazed(unit)</tt></p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isOpposedToLife(unit)</tt></p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.hasExtravision(unit)</tt></p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isBloodsucker(unit)</tt></p> +<p>Simple checks of caste attributes that can be modified by curses.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getMiscTrait(unit, type[, create])</tt></p> +<p>Finds (or creates if requested) a misc trait object with the given id.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isDead(unit)</tt></p> +<p>The unit is completely dead and passive, or a ghost.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isAlive(unit)</tt></p> +<p>The unit isn't dead or undead.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isSane(unit)</tt></p> +<p>The unit is capable of rational action, i.e. not dead, insane, zombie, or active werewolf.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isDwarf(unit)</tt></p> +<p>The unit is of the correct race of the fortress.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.isCitizen(unit)</tt></p> +<p>The unit is an alive sane citizen of the fortress; wraps the +same checks the game uses to decide game-over by extinction.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.units.getAge(unit[,true_age])</span></tt></p> +<p>Returns the age of the unit in years as a floating-point value. +If <tt class="docutils literal">true_age</tt> is true, ignores false identities.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getNominalSkill(unit, skill[, use_rust])</tt></p> +<p>Retrieves the nominal skill level for the given unit. If <tt class="docutils literal">use_rust</tt> +is <em>true</em>, subtracts the rust penalty.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getEffectiveSkill(unit, skill)</tt></p> +<p>Computes the effective rating for the given skill, taking into account exhaustion, pain etc.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.computeMovementSpeed(unit)</tt></p> +<p>Computes number of frames * 100 it takes the unit to move in its current state of mind and body.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getNoblePositions(unit)</tt></p> +<p>Returns a list of tables describing noble position assignments, or <em>nil</em>. +Every table has fields <tt class="docutils literal">entity</tt>, <tt class="docutils literal">assignment</tt> and <tt class="docutils literal">position</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.units.getProfessionName(unit[,ignore_noble,plural])</span></tt></p> +<p>Retrieves the profession name using custom profession, noble assignments +or raws. The <tt class="docutils literal">ignore_noble</tt> boolean disables the use of noble positions.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.units.getCasteProfessionName(race,caste,prof_id[,plural])</span></tt></p> +<p>Retrieves the profession name for the given race/caste using raws.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.units.getProfessionColor(unit[,ignore_noble])</span></tt></p> +<p>Retrieves the color associated with the profession, using noble assignments +or raws. The <tt class="docutils literal">ignore_noble</tt> boolean disables the use of noble positions.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.units.getCasteProfessionColor(race,caste,prof_id)</tt></p> +<p>Retrieves the profession color for the given race/caste using raws.</p> +</li> +</ul> +</div> +<div class="section" id="items-module"> +<h3><a class="toc-backref" href="#id22">Items module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.items.getPosition(item)</tt></p> +<p>Returns true <em>x,y,z</em> of the item, or <em>nil</em> if invalid; may be not equal to item.pos if in inventory.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.getDescription(item, type[, decorate])</tt></p> +<p>Returns the string description of the item, as produced by the getItemDescription +method. If decorate is true, also adds markings for quality and improvements.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.getGeneralRef(item, type)</tt></p> +<p>Searches for a general_ref with the given type.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.getSpecificRef(item, type)</tt></p> +<p>Searches for a specific_ref with the given type.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.getOwner(item)</tt></p> +<p>Returns the owner unit or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.setOwner(item,unit)</tt></p> +<p>Replaces the owner of the item. If unit is <em>nil</em>, removes ownership. +Returns <em>false</em> in case of error.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.getContainer(item)</tt></p> +<p>Returns the container item or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.getContainedItems(item)</tt></p> +<p>Returns a list of items contained in this one.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.moveToGround(item,pos)</tt></p> +<p>Move the item to the ground at position. Returns <em>false</em> if impossible.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.moveToContainer(item,container)</tt></p> +<p>Move the item to the container. Returns <em>false</em> if impossible.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.moveToBuilding(item,building,use_mode)</tt></p> +<p>Move the item to the building. Returns <em>false</em> if impossible.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.moveToInventory(item,unit,use_mode,body_part)</tt></p> +<p>Move the item to the unit inventory. Returns <em>false</em> if impossible.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.remove(item[, no_uncat])</tt></p> +<p>Removes the item, and marks it for garbage collection unless <tt class="docutils literal">no_uncat</tt> is true.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.items.makeProjectile(item)</tt></p> +<p>Turns the item into a projectile, and returns the new object, or <em>nil</em> if impossible.</p> +</li> +</ul> +</div> +<div class="section" id="maps-module"> +<h3><a class="toc-backref" href="#id23">Maps module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getSize()</tt></p> +<p>Returns map size in blocks: <em>x, y, z</em></p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getTileSize()</tt></p> +<p>Returns map size in tiles: <em>x, y, z</em></p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getBlock(x,y,z)</tt></p> +<p>Returns a map block object for given x,y,z in local block coordinates.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.isValidTilePos(coords)</tt>, or isValidTilePos(x,y,z)``</p> +<p>Checks if the given df::coord or x,y,z in local tile coordinates are valid.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getTileBlock(coords)</tt>, or <tt class="docutils literal">getTileBlock(x,y,z)</tt></p> +<p>Returns a map block object for given df::coord or x,y,z in local tile coordinates.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.ensureTileBlock(coords)</tt>, or <tt class="docutils literal">ensureTileBlock(x,y,z)</tt></p> +<p>Like <tt class="docutils literal">getTileBlock</tt>, but if the block is not allocated, try creating it.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getRegionBiome(region_coord2d)</tt>, or <tt class="docutils literal">getRegionBiome(x,y)</tt></p> +<p>Returns the biome info struct for the given global map region.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.maps.enableBlockUpdates(block[,flow,temperature])</span></tt></p> +<p>Enables updates for liquid flow or temperature, unless already active.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.spawnFlow(pos,type,mat_type,mat_index,dimension)</tt></p> +<p>Spawns a new flow (i.e. steam/mist/dust/etc) at the given pos, and with +the given parameters. Returns it, or <em>nil</em> if unsuccessful.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getGlobalInitFeature(index)</tt></p> +<p>Returns the global feature object with the given index.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getLocalInitFeature(region_coord2d,index)</tt></p> +<p>Returns the local feature object with the given region coords and index.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.getTileBiomeRgn(coords)</tt>, or <tt class="docutils literal">getTileBiomeRgn(x,y,z)</tt></p> +<p>Returns <em>x, y</em> for use with <tt class="docutils literal">getRegionBiome</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.maps.canWalkBetween(pos1, pos2)</tt></p> +<p>Checks if a dwarf may be able to walk between the two tiles, +using a pathfinding cache maintained by the game. Note that +this cache is only updated when the game is unpaused, and thus +can get out of date if doors are forbidden or unforbidden, or +tools like liquids or tiletypes are used. It also cannot possibly +take into account anything that depends on the actual units, like +burrows, or the presence of invaders.</p> +</li> +</ul> +</div> +<div class="section" id="burrows-module"> +<h3><a class="toc-backref" href="#id24">Burrows module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.findByName(name)</tt></p> +<p>Returns the burrow pointer or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.clearUnits(burrow)</tt></p> +<p>Removes all units from the burrow.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.isAssignedUnit(burrow,unit)</tt></p> +<p>Checks if the unit is in the burrow.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.setAssignedUnit(burrow,unit,enable)</tt></p> +<p>Adds or removes the unit from the burrow.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.clearTiles(burrow)</tt></p> +<p>Removes all tiles from the burrow.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.listBlocks(burrow)</tt></p> +<p>Returns a table of map block pointers.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.isAssignedTile(burrow,tile_coord)</tt></p> +<p>Checks if the tile is in burrow.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.setAssignedTile(burrow,tile_coord,enable)</tt></p> +<p>Adds or removes the tile from the burrow. Returns <em>false</em> if invalid coords.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.isAssignedBlockTile(burrow,block,x,y)</tt></p> +<p>Checks if the tile within the block is in burrow.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.burrows.setAssignedBlockTile(burrow,block,x,y,enable)</tt></p> +<p>Adds or removes the tile from the burrow. Returns <em>false</em> if invalid coords.</p> +</li> +</ul> +</div> +<div class="section" id="buildings-module"> +<h3><a class="toc-backref" href="#id25">Buildings module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.setOwner(item,unit)</tt></p> +<p>Replaces the owner of the building. If unit is <em>nil</em>, removes ownership. +Returns <em>false</em> in case of error.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.getSize(building)</tt></p> +<p>Returns <em>width, height, centerx, centery</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.findAtTile(pos)</tt>, or <tt class="docutils literal">findAtTile(x,y,z)</tt></p> +<p>Scans the buildings for the one located at the given tile. +Does not work on civzones. Warning: linear scan if the map +tile indicates there are buildings at it.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.findCivzonesAt(pos)</tt>, or <tt class="docutils literal">findCivzonesAt(x,y,z)</tt></p> +<p>Scans civzones, and returns a lua sequence of those that touch +the given tile, or <em>nil</em> if none.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.getCorrectSize(width, height, type, subtype, custom, direction)</tt></p> +<p>Computes correct dimensions for the specified building type and orientation, +using width and height for flexible dimensions. +Returns <em>is_flexible, width, height, center_x, center_y</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.buildings.checkFreeTiles(pos,size[,extents,change_extents,allow_occupied])</span></tt></p> +<p>Checks if the rectangle defined by <tt class="docutils literal">pos</tt> and <tt class="docutils literal">size</tt>, and possibly extents, +can be used for placing a building. If <tt class="docutils literal">change_extents</tt> is true, bad tiles +are removed from extents. If <tt class="docutils literal">allow_occupied</tt>, the occupancy test is skipped.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.countExtentTiles(extents,defval)</tt></p> +<p>Returns the number of tiles included by extents, or defval.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.containsTile(building, x, y[, room])</tt></p> +<p>Checks if the building contains the specified tile, either directly, or as room.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.hasSupport(pos,size)</tt></p> +<p>Checks if a bridge constructed at specified position would have +support from terrain, and thus won't collapse if retracted.</p> +</li> +</ul> +<p>Low-level building creation functions;</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.allocInstance(pos, type, subtype, custom)</tt></p> +<p>Creates a new building instance of given type, subtype and custom type, +at specified position. Returns the object, or <em>nil</em> in case of an error.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.setSize(building, width, height, direction)</tt></p> +<p>Configures an object returned by <tt class="docutils literal">allocInstance</tt>, using specified +parameters wherever appropriate. If the building has fixed size along +any dimension, the corresponding input parameter will be ignored. +Returns <em>false</em> if the building cannot be placed, or <em>true, width, +height, rect_area, true_area</em>. Returned width and height are the +final values used by the building; true_area is less than rect_area +if any tiles were removed from designation.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.constructAbstract(building)</tt></p> +<p>Links a fully configured object created by <tt class="docutils literal">allocInstance</tt> into the +world. The object must be an abstract building, i.e. a stockpile or civzone. +Returns <em>true</em>, or <em>false</em> if impossible.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.constructWithItems(building, items)</tt></p> +<p>Links a fully configured object created by <tt class="docutils literal">allocInstance</tt> into the +world for construction, using a list of specific items as material. +Returns <em>true</em>, or <em>false</em> if impossible.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.constructWithFilters(building, job_items)</tt></p> +<p>Links a fully configured object created by <tt class="docutils literal">allocInstance</tt> into the +world for construction, using a list of job_item filters as inputs. +Returns <em>true</em>, or <em>false</em> if impossible. Filter objects are claimed +and possibly destroyed in any case. +Use a negative <tt class="docutils literal">quantity</tt> field value to auto-compute the amount +from the size of the building.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.deconstruct(building)</tt></p> +<p>Destroys the building, or queues a deconstruction job. +Returns <em>true</em> if the building was destroyed and deallocated immediately.</p> +</li> +</ul> +<p>More high-level functions are implemented in lua and can be loaded by +<tt class="docutils literal"><span class="pre">require('dfhack.buildings')</span></tt>. See <tt class="docutils literal">hack/lua/dfhack/buildings.lua</tt>.</p> +<p>Among them are:</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.buildings.getFiltersByType(argtable,type,subtype,custom)</tt></p> +<p>Returns a sequence of lua structures, describing input item filters +suitable for the specified building type, or <em>nil</em> if unknown or invalid. +The returned sequence is suitable for use as the <tt class="docutils literal">job_items</tt> argument +of <tt class="docutils literal">constructWithFilters</tt>. +Uses tables defined in <tt class="docutils literal">buildings.lua</tt>.</p> +<p>Argtable members <tt class="docutils literal">material</tt> (the default name), <tt class="docutils literal">bucket</tt>, <tt class="docutils literal">barrel</tt>, +<tt class="docutils literal">chain</tt>, <tt class="docutils literal">mechanism</tt>, <tt class="docutils literal">screw</tt>, <tt class="docutils literal">pipe</tt>, <tt class="docutils literal">anvil</tt>, <tt class="docutils literal">weapon</tt> are used to +augment the basic attributes with more detailed information if the +building has input items with the matching name (see the tables for naming details). +Note that it is impossible to <em>override</em> any properties this way, only supply those that +are not mentioned otherwise; one exception is that flags2.non_economic +is automatically cleared if an explicit material is specified.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.buildings.constructBuilding{...}</span></tt></p> +<p>Creates a building in one call, using options contained +in the argument table. Returns the building, or <em>nil, error</em>.</p> +<p><strong>NOTE:</strong> Despite the name, unless the building is abstract, +the function creates it in an 'unconstructed' stage, with +a queued in-game job that will actually construct it. I.e. +the function replicates programmatically what can be done +through the construct building menu in the game ui, except +that it does less environment constraint checking.</p> +<p>The following options can be used:</p> +<ul> +<li><p class="first"><tt class="docutils literal">pos = coordinates</tt>, or <tt class="docutils literal">x = <span class="pre">...,</span> y = <span class="pre">...,</span> z = ...</tt></p> +<p>Mandatory. Specifies the left upper corner of the building.</p> +</li> +<li><p class="first"><tt class="docutils literal">type = df.building_type.FOO, subtype = <span class="pre">...,</span> custom = ...</tt></p> +<p>Mandatory. Specifies the type of the building. Obviously, subtype +and custom are only expected if the type requires them.</p> +</li> +<li><p class="first"><tt class="docutils literal">fields = { ... }</tt></p> +<p>Initializes fields of the building object after creation with <tt class="docutils literal">df.assign</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">width = <span class="pre">...,</span> height = <span class="pre">...,</span> direction = ...</tt></p> +<p>Sets size and orientation of the building. If it is +fixed-size, specified dimensions are ignored.</p> +</li> +<li><p class="first"><tt class="docutils literal">full_rectangle = true</tt></p> +<p>For buildings like stockpiles or farm plots that can normally +accomodate individual tile exclusion, forces an error if any +tiles within the specified width*height are obstructed.</p> +</li> +<li><p class="first"><tt class="docutils literal">items = { item, item ... }</tt>, or <tt class="docutils literal">filters = { <span class="pre">{...},</span> <span class="pre">{...}...</span> }</tt></p> +<p>Specifies explicit items or item filters to use in construction. +It is the job of the user to ensure they are correct for the building type.</p> +</li> +<li><p class="first"><tt class="docutils literal">abstract = true</tt></p> +<p>Specifies that the building is abstract and does not require construction. +Required for stockpiles and civzones; an error otherwise.</p> +</li> +<li><p class="first"><tt class="docutils literal">material = <span class="pre">{...},</span> mechanism = <span class="pre">{...},</span> ...</tt></p> +<p>If none of <tt class="docutils literal">items</tt>, <tt class="docutils literal">filter</tt>, or <tt class="docutils literal">abstract</tt> is used, +the function uses <tt class="docutils literal">getFiltersByType</tt> to compute the input +item filters, and passes the argument table through. If no filters +can be determined this way, <tt class="docutils literal">constructBuilding</tt> throws an error.</p> +</li> +</ul> +</li> +</ul> +</div> +<div class="section" id="constructions-module"> +<h3><a class="toc-backref" href="#id26">Constructions module</a></h3> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.constructions.designateNew(pos,type,item_type,mat_index)</tt></p> +<p>Designates a new construction at given position. If there already is +a planned but not completed construction there, changes its type. +Returns <em>true</em>, or <em>false</em> if obstructed. +Note that designated constructions are technically buildings.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.constructions.designateRemove(pos)</tt>, or <tt class="docutils literal">designateRemove(x,y,z)</tt></p> +<p>If there is a construction or a planned construction at the specified +coordinates, designates it for removal, or instantly cancels the planned one. +Returns <em>true, was_only_planned</em> if removed; or <em>false</em> if none found.</p> +</li> +</ul> +</div> +<div class="section" id="screen-api"> +<h3><a class="toc-backref" href="#id27">Screen API</a></h3> +<p>The screen module implements support for drawing to the tiled screen of the game. +Note that drawing only has any effect when done from callbacks, so it can only +be feasibly used in the core context.</p> +<p>Basic painting functions:</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.screen.getWindowSize()</tt></p> +<p>Returns <em>width, height</em> of the screen.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.getMousePos()</tt></p> +<p>Returns <em>x,y</em> of the tile the mouse is over.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.inGraphicsMode()</tt></p> +<p>Checks if [GRAPHICS:YES] was specified in init.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.screen.paintTile(pen,x,y[,char,tile])</span></tt></p> +<p>Paints a tile using given parameters. Pen is a table with following possible fields:</p> +<dl class="docutils"> +<dt><tt class="docutils literal">ch</tt></dt> +<dd><p class="first last">Provides the ordinary tile character, as either a 1-character string or a number. +Can be overridden with the <tt class="docutils literal">char</tt> function parameter.</p> +</dd> +<dt><tt class="docutils literal">fg</tt></dt> +<dd><p class="first last">Foreground color for the ordinary tile. Defaults to COLOR_GREY (7).</p> +</dd> +<dt><tt class="docutils literal">bg</tt></dt> +<dd><p class="first last">Background color for the ordinary tile. Defaults to COLOR_BLACK (0).</p> +</dd> +<dt><tt class="docutils literal">bold</tt></dt> +<dd><p class="first last">Bright/bold text flag. If <em>nil</em>, computed based on (fg & 8); fg is masked to 3 bits. +Otherwise should be <em>true/false</em>.</p> +</dd> +<dt><tt class="docutils literal">tile</tt></dt> +<dd><p class="first last">Graphical tile id. Ignored unless [GRAPHICS:YES] was in init.txt.</p> +</dd> +<dt><tt class="docutils literal">tile_color = true</tt></dt> +<dd><p class="first last">Specifies that the tile should be shaded with <em>fg/bg</em>.</p> +</dd> +<dt><tt class="docutils literal">tile_fg, tile_bg</tt></dt> +<dd><p class="first last">If specified, overrides <em>tile_color</em> and supplies shading colors directly.</p> +</dd> +</dl> +<p>Returns <em>false</em> if coordinates out of bounds, or other error.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.readTile(x,y)</tt></p> +<p>Retrieves the contents of the specified tile from the screen buffers. +Returns a pen, or <em>nil</em> if invalid or TrueType.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.paintString(pen,x,y,text)</tt></p> +<p>Paints the string starting at <em>x,y</em>. Uses the string characters +in sequence to override the <tt class="docutils literal">ch</tt> field of pen.</p> +<p>Returns <em>true</em> if painting at least one character succeeded.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.fillRect(pen,x1,y1,x2,y2)</tt></p> +<p>Fills the rectangle specified by the coordinates with the given pen. +Returns <em>true</em> if painting at least one character succeeded.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.findGraphicsTile(pagename,x,y)</tt></p> +<p>Finds a tile from a graphics set (i.e. the raws used for creatures), +if in graphics mode and loaded.</p> +<p>Returns: <em>tile, tile_grayscale</em>, or <em>nil</em> if not found. +The values can then be used for the <em>tile</em> field of <em>pen</em> structures.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.clear()</tt></p> +<p>Fills the screen with blank background.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.invalidate()</tt></p> +<p>Requests repaint of the screen by setting a flag. Unlike other +functions in this section, this may be used at any time.</p> +</li> +</ul> +<p>In order to actually be able to paint to the screen, it is necessary +to create and register a viewscreen (basically a modal dialog) with +the game.</p> +<p><strong>NOTE</strong>: As a matter of policy, in order to avoid user confusion, all +interface screens added by dfhack should bear the "DFHack" signature.</p> +<p>Screens are managed with the following functions:</p> +<ul> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.screen.show(screen[,below])</span></tt></p> +<p>Displays the given screen, possibly placing it below a different one. +The screen must not be already shown. Returns <em>true</em> if success.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.screen.dismiss(screen[,to_first])</span></tt></p> +<p>Marks the screen to be removed when the game enters its event loop. +If <tt class="docutils literal">to_first</tt> is <em>true</em>, all screens up to the first one will be deleted.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.screen.isDismissed(screen)</tt></p> +<p>Checks if the screen is already marked for removal.</p> +</li> +</ul> +<p>Apart from a native viewscreen object, these functions accept a table +as a screen. In this case, <tt class="docutils literal">show</tt> creates a new native viewscreen +that delegates all processing to methods stored in that table.</p> +<p><strong>NOTE</strong>: Lua-implemented screens are only supported in the core context.</p> +<p>Supported callbacks and fields are:</p> +<ul> +<li><p class="first"><tt class="docutils literal">screen._native</tt></p> +<p>Initialized by <tt class="docutils literal">show</tt> with a reference to the backing viewscreen +object, and removed again when the object is deleted.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onShow()</tt></p> +<p>Called by <tt class="docutils literal">dfhack.screen.show</tt> if successful.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onDismiss()</tt></p> +<p>Called by <tt class="docutils literal">dfhack.screen.dismiss</tt> if successful.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onDestroy()</tt></p> +<p>Called from the destructor when the viewscreen is deleted.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onResize(w, h)</tt></p> +<p>Called before <tt class="docutils literal">onRender</tt> or <tt class="docutils literal">onIdle</tt> when the window size has changed.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onRender()</tt></p> +<p>Called when the viewscreen should paint itself. This is the only context +where the above painting functions work correctly.</p> +<p>If omitted, the screen is cleared; otherwise it should do that itself. +In order to make a see-through dialog, call <tt class="docutils literal">self._native.parent:render()</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onIdle()</tt></p> +<p>Called every frame when the screen is on top of the stack.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onHelp()</tt></p> +<p>Called when the help keybinding is activated (usually '?').</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onInput(keys)</tt></p> +<p>Called when keyboard or mouse events are available. +If any keys are pressed, the keys argument is a table mapping them to <em>true</em>. +Note that this refers to logical keybingings computed from real keys via +options; if multiple interpretations exist, the table will contain multiple keys.</p> +<p>The table also may contain special keys:</p> +<dl class="docutils"> +<dt><tt class="docutils literal">_STRING</tt></dt> +<dd><p class="first last">Maps to an integer in range 0-255. Duplicates a separate "STRING_A???" code for convenience.</p> +</dd> +<dt><tt class="docutils literal">_MOUSE_L, _MOUSE_R</tt></dt> +<dd><p class="first last">If the left or right mouse button is pressed.</p> +</dd> +</dl> +<p>If this method is omitted, the screen is dismissed on receival of the <tt class="docutils literal">LEAVESCREEN</tt> key.</p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onGetSelectedUnit()</tt></p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onGetSelectedItem()</tt></p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onGetSelectedJob()</tt></p> +</li> +<li><p class="first"><tt class="docutils literal">function screen:onGetSelectedBuilding()</tt></p> +<p>Implement these to provide a return value for the matching +<tt class="docutils literal"><span class="pre">dfhack.gui.getSelected...</span></tt> function.</p> +</li> +</ul> +</div> +<div class="section" id="internal-api"> +<h3><a class="toc-backref" href="#id28">Internal API</a></h3> +<p>These functions are intended for the use by dfhack developers, +and are only documented here for completeness:</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.internal.scripts</tt></p> +<p>The table used by <tt class="docutils literal">dfhack.run_script()</tt> to give every script its own +global environment, persistent between calls to the script.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.getAddress(name)</tt></p> +<p>Returns the global address <tt class="docutils literal">name</tt>, or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.setAddress(name, value)</tt></p> +<p>Sets the global address <tt class="docutils literal">name</tt>. Returns the value of <tt class="docutils literal">getAddress</tt> before the change.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.getVTable(name)</tt></p> +<p>Returns the pre-extracted vtable address <tt class="docutils literal">name</tt>, or <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.getRebaseDelta()</tt></p> +<p>Returns the ASLR rebase offset of the DF executable.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.getMemRanges()</tt></p> +<p>Returns a sequence of tables describing virtual memory ranges of the process.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.patchMemory(dest,src,count)</tt></p> +<p>Like memmove below, but works even if dest is read-only memory, e.g. code. +If destination overlaps a completely invalid memory region, or another error +occurs, returns false.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.memmove(dest,src,count)</tt></p> +<p>Wraps the standard memmove function. Accepts both numbers and refs as pointers.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.memcmp(ptr1,ptr2,count)</tt></p> +<p>Wraps the standard memcmp function.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.memscan(haystack,count,step,needle,nsize)</tt></p> +<p>Searches for <tt class="docutils literal">needle</tt> of <tt class="docutils literal">nsize</tt> bytes in <tt class="docutils literal">haystack</tt>, +using <tt class="docutils literal">count</tt> steps of <tt class="docutils literal">step</tt> bytes. +Returns: <em>step_idx, sum_idx, found_ptr</em>, or <em>nil</em> if not found.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.internal.diffscan(old_data, new_data, start_idx, end_idx, eltsize[, oldval, newval, delta])</tt></p> +<p>Searches for differences between buffers at ptr1 and ptr2, as integers of size eltsize. +The oldval, newval or delta arguments may be used to specify additional constraints. +Returns: <em>found_index</em>, or <em>nil</em> if end reached.</p> +</li> +</ul> +</div> +</div> +<div class="section" id="core-interpreter-context"> +<h2><a class="toc-backref" href="#id29">Core interpreter context</a></h2> +<p>While plugins can create any number of interpreter instances, +there is one special context managed by dfhack core. It is the +only context that can receive events from DF and plugins.</p> +<p>Core context specific functions:</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.is_core_context</tt></p> +<p>Boolean value; <em>true</em> in the core context.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.timeout(time,mode,callback)</tt></p> +<p>Arranges for the callback to be called once the specified +period of time passes. The <tt class="docutils literal">mode</tt> argument specifies the +unit of time used, and may be one of <tt class="docutils literal">'frames'</tt> (raw FPS), +<tt class="docutils literal">'ticks'</tt> (unpaused FPS), <tt class="docutils literal">'days'</tt>, <tt class="docutils literal">'months'</tt>, +<tt class="docutils literal">'years'</tt> (in-game time). All timers other than +<tt class="docutils literal">'frames'</tt> are cancelled when the world is unloaded, +and cannot be queued until it is loaded again. +Returns the timer id, or <em>nil</em> if unsuccessful due to +world being unloaded.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.timeout_active(id[,new_callback])</span></tt></p> +<p>Returns the active callback with the given id, or <em>nil</em> +if inactive or nil id. If called with 2 arguments, replaces +the current callback with the given value, if still active. +Using <tt class="docutils literal">timeout_active(id,nil)</tt> cancels the timer.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.onStateChange.foo = function(code)</tt></p> +<p>Event. Receives the same codes as plugin_onstatechange in C++.</p> +</li> +</ul> +<div class="section" id="event-type"> +<h3><a class="toc-backref" href="#id30">Event type</a></h3> +<p>An event is a native object transparently wrapping a lua table, +and implementing a __call metamethod. When it is invoked, it loops +through the table with next and calls all contained values. +This is intended as an extensible way to add listeners.</p> +<p>This type itself is available in any context, but only the +core context has the actual events defined by C++ code.</p> +<p>Features:</p> +<ul> +<li><p class="first"><tt class="docutils literal">dfhack.event.new()</tt></p> +<p>Creates a new instance of an event.</p> +</li> +<li><p class="first"><tt class="docutils literal">event[key] = function</tt></p> +<p>Sets the function as one of the listeners. Assign <em>nil</em> to remove it.</p> +<p><strong>NOTE</strong>: The <tt class="docutils literal">df.NULL</tt> key is reserved for the use by +the C++ owner of the event; it is an error to try setting it.</p> +</li> +<li><p class="first"><tt class="docutils literal">#event</tt></p> +<p>Returns the number of non-nil listeners.</p> +</li> +<li><p class="first"><tt class="docutils literal">pairs(event)</tt></p> +<p>Iterates over all listeners in the table.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">event(args...)</span></tt></p> +<p>Invokes all listeners contained in the event in an arbitrary +order using <tt class="docutils literal">dfhack.safecall</tt>.</p> +</li> +</ul> +</div> +</div> +</div> +<div class="section" id="lua-modules"> +<h1><a class="toc-backref" href="#id31">Lua Modules</a></h1> +<p>DFHack sets up the lua interpreter so that the built-in <tt class="docutils literal">require</tt> +function can be used to load shared lua code from hack/lua/. +The <tt class="docutils literal">dfhack</tt> namespace reference itself may be obtained via +<tt class="docutils literal"><span class="pre">require('dfhack')</span></tt>, although it is initially created as a +global by C++ bootstrap code.</p> +<p>The following module management functions are provided:</p> +<ul> +<li><p class="first"><tt class="docutils literal">mkmodule(name)</tt></p> +<p>Creates an environment table for the module. Intended to be used as:</p> +<pre class="literal-block"> +local _ENV = mkmodule('foo') +... +return _ENV +</pre> +<p>If called the second time, returns the same table; thus providing reload support.</p> +</li> +<li><p class="first"><tt class="docutils literal">reload(name)</tt></p> +<p>Reloads a previously <tt class="docutils literal">require</tt>-d module <em>"name"</em> from the file. +Intended as a help for module development.</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.BASE_G</tt></p> +<p>This variable contains the root global environment table, which is +used as a base for all module and script environments. Its contents +should be kept limited to the standard Lua library and API described +in this document.</p> +</li> +</ul> +<div class="section" id="global-environment"> +<h2><a class="toc-backref" href="#id32">Global environment</a></h2> +<p>A number of variables and functions are provided in the base global +environment by the mandatory init file dfhack.lua:</p> +<ul> +<li><p class="first">Color constants</p> +<p>These are applicable both for <tt class="docutils literal">dfhack.color()</tt> and color fields +in DF functions or structures:</p> +<p>COLOR_RESET, COLOR_BLACK, COLOR_BLUE, COLOR_GREEN, COLOR_CYAN, +COLOR_RED, COLOR_MAGENTA, COLOR_BROWN, COLOR_GREY, COLOR_DARKGREY, +COLOR_LIGHTBLUE, COLOR_LIGHTGREEN, COLOR_LIGHTCYAN, COLOR_LIGHTRED, +COLOR_LIGHTMAGENTA, COLOR_YELLOW, COLOR_WHITE</p> +</li> +<li><p class="first"><tt class="docutils literal">dfhack.onStateChange</tt> event codes</p> +<p>Available only in the core context, as is the event itself:</p> +<p>SC_WORLD_LOADED, SC_WORLD_UNLOADED, SC_MAP_LOADED, +SC_MAP_UNLOADED, SC_VIEWSCREEN_CHANGED, SC_CORE_INITIALIZED</p> +</li> +<li><p class="first">Functions already described above</p> +<p>safecall, qerror, mkmodule, reload</p> +</li> +<li><p class="first"><tt class="docutils literal">printall(obj)</tt></p> +<p>If the argument is a lua table or DF object reference, prints all fields.</p> +</li> +<li><p class="first"><tt class="docutils literal">copyall(obj)</tt></p> +<p>Returns a shallow copy of the table or reference as a lua table.</p> +</li> +<li><p class="first"><tt class="docutils literal">pos2xyz(obj)</tt></p> +<p>The object must have fields x, y and z. Returns them as 3 values. +If obj is <em>nil</em>, or x is -30000 (the usual marker for undefined +coordinates), returns <em>nil</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">xyz2pos(x,y,z)</tt></p> +<p>Returns a table with x, y and z as fields.</p> +</li> +<li><p class="first"><tt class="docutils literal"><span class="pre">safe_index(obj,index...)</span></tt></p> +<p>Walks a sequence of dereferences, which may be represented by numbers or strings. +Returns <em>nil</em> if any of obj or indices is <em>nil</em>, or a numeric index is out of array bounds.</p> +</li> +</ul> +</div> +<div class="section" id="utils"> +<h2><a class="toc-backref" href="#id33">utils</a></h2> +<ul> +<li><p class="first"><tt class="docutils literal">utils.compare(a,b)</tt></p> +<p>Comparator function; returns <em>-1</em> if a<b, <em>1</em> if a>b, <em>0</em> otherwise.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.compare_name(a,b)</tt></p> +<p>Comparator for names; compares empty string last.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.is_container(obj)</tt></p> +<p>Checks if obj is a container ref.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.make_index_sequence(start,end)</tt></p> +<p>Returns a lua sequence of numbers in start..end.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.make_sort_order(data, ordering)</tt></p> +<p>Computes a sorted permutation of objects in data, as a table of integer +indices into the data sequence. Uses <tt class="docutils literal">data.n</tt> as input length +if present.</p> +<p>The ordering argument is a sequence of ordering specs, represented +as lua tables with following possible fields:</p> +<dl class="docutils"> +<dt>ord.key = <em>function(value)</em></dt> +<dd><p class="first last">Computes comparison key from input data value. Not called on nil. +If omitted, the comparison key is the value itself.</p> +</dd> +<dt>ord.key_table = <em>function(data)</em></dt> +<dd><p class="first last">Computes a key table from the data table in one go.</p> +</dd> +<dt>ord.compare = <em>function(a,b)</em></dt> +<dd><p class="first last">Comparison function. Defaults to <tt class="docutils literal">utils.compare</tt> above. +Called on non-nil keys; nil sorts last.</p> +</dd> +<dt>ord.nil_first = <em>true/false</em></dt> +<dd><p class="first last">If true, nil keys are sorted first instead of last.</p> +</dd> +<dt>ord.reverse = <em>true/false</em></dt> +<dd><p class="first last">If true, sort non-nil keys in descending order.</p> +</dd> +</dl> +<p>For every comparison during sorting the specs are applied in +order until an unambiguous decision is reached. Sorting is stable.</p> +<p>Example of sorting a sequence by field foo:</p> +<pre class="literal-block"> +local spec = { key = function(v) return v.foo end } +local order = utils.make_sort_order(data, { spec }) +local output = {} +for i = 1,#order do output[i] = data[order[i]] end +</pre> +<p>Separating the actual reordering of the sequence in this +way enables applying the same permutation to multiple arrays. +This function is used by the sort plugin.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.assign(tgt, src)</tt></p> +<p>Does a recursive assignment of src into tgt. +Uses <tt class="docutils literal">df.assign</tt> if tgt is a native object ref; otherwise +recurses into lua tables.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.clone(obj, deep)</tt></p> +<p>Performs a shallow, or semi-deep copy of the object as a lua table tree. +The deep mode recurses into lua tables and subobjects, except pointers +to other heap objects. +Null pointers are represented as df.NULL. Zero-based native containers +are converted to 1-based lua sequences.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.clone_with_default(obj, default, force)</tt></p> +<p>Copies the object, using the <tt class="docutils literal">default</tt> lua table tree +as a guide to which values should be skipped as uninteresting. +The <tt class="docutils literal">force</tt> argument makes it always return a non-<em>nil</em> value.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.sort_vector(vector,field,cmpfun)</tt></p> +<p>Sorts a native vector or lua sequence using the comparator function. +If <tt class="docutils literal">field</tt> is not <em>nil</em>, applies the comparator to the field instead +of the whole object.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.binsearch(vector,key,field,cmpfun,min,max)</tt></p> +<p>Does a binary search in a native vector or lua sequence for +<tt class="docutils literal">key</tt>, using <tt class="docutils literal">cmpfun</tt> and <tt class="docutils literal">field</tt> like sort_vector. +If <tt class="docutils literal">min</tt> and <tt class="docutils literal">max</tt> are specified, they are used as the +search subrange bounds.</p> +<p>If found, returns <em>item, true, idx</em>. Otherwise returns +<em>nil, false, insert_idx</em>, where <em>insert_idx</em> is the correct +insertion point.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.insert_sorted(vector,item,field,cmpfun)</tt></p> +<p>Does a binary search, and inserts item if not found. +Returns <em>did_insert, vector[idx], idx</em>.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.insert_or_update(vector,item,field,cmpfun)</tt></p> +<p>Like <tt class="docutils literal">insert_sorted</tt>, but also assigns the item into +the vector cell if insertion didn't happen.</p> +<p>As an example, you can use this to set skill values:</p> +<pre class="literal-block"> +utils.insert_or_update(soul.skills, {new=true, id=..., rating=...}, 'id') +</pre> +<p>(For an explanation of <tt class="docutils literal">new=true</tt>, see table assignment in the wrapper section)</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.prompt_yes_no(prompt, default)</tt></p> +<p>Presents a yes/no prompt to the user. If <tt class="docutils literal">default</tt> is not <em>nil</em>, +allows just pressing Enter to submit the default choice. +If the user enters <tt class="docutils literal">'abort'</tt>, throws an error.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.prompt_input(prompt, checkfun, quit_str)</tt></p> +<p>Presents a prompt to input data, until a valid string is entered. +Once <tt class="docutils literal">checkfun(input)</tt> returns <em>true, ...</em>, passes the values +through. If the user enters the quit_str (defaults to <tt class="docutils literal"><span class="pre">'~~~'</span></tt>), +throws an error.</p> +</li> +<li><p class="first"><tt class="docutils literal">utils.check_number(text)</tt></p> +<p>A <tt class="docutils literal">prompt_input</tt> <tt class="docutils literal">checkfun</tt> that verifies a number input.</p> +</li> +</ul> +</div> +<div class="section" id="dumper"> +<h2><a class="toc-backref" href="#id34">dumper</a></h2> +<p>A third-party lua table dumper module from +<a class="reference external" href="http://lua-users.org/wiki/DataDumper">http://lua-users.org/wiki/DataDumper</a>. Defines one +function:</p> +<ul> +<li><p class="first"><tt class="docutils literal">dumper.DataDumper(value, varname, fastmode, ident, indent_step)</tt></p> +<p>Returns <tt class="docutils literal">value</tt> converted to a string. The <tt class="docutils literal">indent_step</tt> +argument specifies the indentation step size in spaces. For +the other arguments see the original documentation link above.</p> +</li> +</ul> +</div> +<div class="section" id="class"> +<h2><a class="toc-backref" href="#id35">class</a></h2> +<p>Implements a trivial single-inheritance class system.</p> +<ul> +<li><p class="first"><tt class="docutils literal">Foo = defclass(Foo[, ParentClass])</tt></p> +<p>Defines or updates class Foo. The <tt class="docutils literal">Foo = defclass(Foo)</tt> syntax +is needed so that when the module or script is reloaded, the +class identity will be preserved through the preservation of +global variable values.</p> +<p>The <tt class="docutils literal">defclass</tt> function is defined as a stub in the global +namespace, and using it will auto-load the class module.</p> +</li> +<li><p class="first"><tt class="docutils literal">Class.super</tt></p> +<p>This class field is set by defclass to the parent class, and +allows a readable <tt class="docutils literal">Class.super.method(self, <span class="pre">...)</span></tt> syntax for +calling superclass methods.</p> +</li> +<li><p class="first"><tt class="docutils literal">Class.ATTRS { foo = xxx, bar = yyy }</tt></p> +<p>Declares certain instance fields to be attributes, i.e. auto-initialized +from fields in the table used as the constructor argument. If omitted, +they are initialized with the default values specified in this declaration.</p> +<p>If the default value should be <em>nil</em>, use <tt class="docutils literal">ATTRS { foo = DEFAULT_NIL }</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">new_obj = Class{ foo = arg, bar = arg, ... }</tt></p> +<p>Calling the class as a function creates and initializes a new instance. +Initialization happens in this order:</p> +<ol class="arabic simple"> +<li>An empty instance table is created, and its metatable set.</li> +<li>The <tt class="docutils literal">preinit</tt> method is called via <tt class="docutils literal">invoke_before</tt> (see below) +with the table used as argument to the class. This method is intended +for validating and tweaking that argument table.</li> +<li>Declared ATTRS are initialized from the argument table or their default values.</li> +<li>The <tt class="docutils literal">init</tt> method is called via <tt class="docutils literal">invoke_after</tt> with the argument table. +This is the main constructor method.</li> +<li>The <tt class="docutils literal">postinit</tt> method is called via <tt class="docutils literal">invoke_after</tt> with the argument table. +Place code that should be called after the object is fully constructed here.</li> +</ol> +</li> +</ul> +<p>Predefined instance methods:</p> +<ul> +<li><p class="first"><tt class="docutils literal">instance:assign{ foo = xxx }</tt></p> +<p>Assigns all values in the input table to the matching instance fields.</p> +</li> +<li><p class="first"><tt class="docutils literal">instance:callback(method_name, <span class="pre">[args...])</span></tt></p> +<p>Returns a closure that invokes the specified method of the class, +properly passing in self, and optionally a number of initial arguments too. +The arguments given to the closure are appended to these.</p> +</li> +<li><p class="first"><tt class="docutils literal">instance:invoke_before(method_name, <span class="pre">args...)</span></tt></p> +<p>Navigates the inheritance chain of the instance starting from the most specific +class, and invokes the specified method with the arguments if it is defined in +that specific class. Equivalent to the following definition in every class:</p> +<pre class="literal-block"> +function Class:invoke_before(method, ...) + if rawget(Class, method) then + rawget(Class, method)(self, ...) + end + Class.super.invoke_before(method, ...) +end +</pre> +</li> +<li><p class="first"><tt class="docutils literal">instance:invoke_after(method_name, <span class="pre">args...)</span></tt></p> +<p>Like invoke_before, only the method is called after the recursive call to super, +i.e. invocations happen in the parent to child order.</p> +<p>These two methods are inspired by the Common Lisp before and after methods, and +are intended for implementing similar protocols for certain things. The class +library itself uses them for constructors.</p> +</li> +</ul> +<p>To avoid confusion, these methods cannot be redefined.</p> +</div> +</div> +<div class="section" id="plugins"> +<h1><a class="toc-backref" href="#id36">Plugins</a></h1> +<p>DFHack plugins may export native functions and events +to lua contexts. They are automatically imported by +<tt class="docutils literal"><span class="pre">mkmodule('plugins.<name>')</span></tt>; this means that a lua +module file is still necessary for <tt class="docutils literal">require</tt> to read.</p> +<p>The following plugins have lua support.</p> +<div class="section" id="burrows"> +<h2><a class="toc-backref" href="#id37">burrows</a></h2> +<p>Implements extended burrow manipulations.</p> +<p>Events:</p> +<ul> +<li><p class="first"><tt class="docutils literal">onBurrowRename.foo = function(burrow)</tt></p> +<p>Emitted when a burrow might have been renamed either through +the game UI, or <tt class="docutils literal">renameBurrow()</tt>.</p> +</li> +<li><p class="first"><tt class="docutils literal">onDigComplete.foo = function(job_type,pos,old_tiletype,new_tiletype,worker)</tt></p> +<p>Emitted when a tile might have been dug out. Only tracked if the +auto-growing burrows feature is enabled.</p> +</li> +</ul> +<p>Native functions:</p> +<ul> +<li><p class="first"><tt class="docutils literal">renameBurrow(burrow,name)</tt></p> +<p>Renames the burrow, emitting <tt class="docutils literal">onBurrowRename</tt> and updating auto-grow state properly.</p> +</li> +<li><p class="first"><tt class="docutils literal">findByName(burrow,name)</tt></p> +<p>Finds a burrow by name, using the same rules as the plugin command line interface. +Namely, trailing <tt class="docutils literal">'+'</tt> characters marking auto-grow burrows are ignored.</p> +</li> +<li><p class="first"><tt class="docutils literal">copyUnits(target,source,enable)</tt></p> +<p>Applies units from <tt class="docutils literal">source</tt> burrow to <tt class="docutils literal">target</tt>. The <tt class="docutils literal">enable</tt> +parameter specifies if they are to be added or removed.</p> +</li> +<li><p class="first"><tt class="docutils literal">copyTiles(target,source,enable)</tt></p> +<p>Applies tiles from <tt class="docutils literal">source</tt> burrow to <tt class="docutils literal">target</tt>. The <tt class="docutils literal">enable</tt> +parameter specifies if they are to be added or removed.</p> +</li> +<li><p class="first"><tt class="docutils literal">setTilesByKeyword(target,keyword,enable)</tt></p> +<p>Adds or removes tiles matching a predefined keyword. The keyword +set is the same as used by the command line.</p> +</li> +</ul> +<p>The lua module file also re-exports functions from <tt class="docutils literal">dfhack.burrows</tt>.</p> +</div> +<div class="section" id="sort"> +<h2><a class="toc-backref" href="#id38">sort</a></h2> +<p>Does not export any native functions as of now. Instead, it +calls lua code to perform the actual ordering of list items.</p> +</div> +</div> +<div class="section" id="scripts"> +<h1><a class="toc-backref" href="#id39">Scripts</a></h1> +<p>Any files with the .lua extension placed into hack/scripts/* +are automatically used by the DFHack core as commands. The +matching command name consists of the name of the file sans +the extension.</p> +<p>If the first line of the script is a one-line comment, it is +used by the built-in <tt class="docutils literal">ls</tt> and <tt class="docutils literal">help</tt> commands.</p> +<p><strong>NOTE:</strong> Scripts placed in subdirectories still can be accessed, but +do not clutter the <tt class="docutils literal">ls</tt> command list; thus it is preferred +for obscure developer-oriented scripts and scripts used by tools. +When calling such scripts, always use '/' as the separator for +directories, e.g. <tt class="docutils literal"><span class="pre">devel/lua-example</span></tt>.</p> +<p>Scripts are re-read from disk every time they are used +(this may be changed later to check the file change time); however +the global variable values persist in memory between calls. +Every script gets its own separate environment for global +variables.</p> +<p>Arguments are passed in to the scripts via the <strong>...</strong> built-in +quasi-variable; when the script is called by the DFHack core, +they are all guaranteed to be non-nil strings.</p> +<p>DFHack core invokes the scripts in the <em>core context</em> (see above); +however it is possible to call them from any lua code (including +from other scripts) in any context, via the same function the core uses:</p> +<ul> +<li><p class="first"><tt class="docutils literal"><span class="pre">dfhack.run_script(name[,args...])</span></tt></p> +<p>Run a lua script in hack/scripts/, as if it was started from dfhack command-line. +The <tt class="docutils literal">name</tt> argument should be the name stem, as would be used on the command line.</p> +</li> +</ul> +<p>Note that this function lets errors propagate to the caller.</p> +</div> +</div> +</body> +</html> diff --git a/Readme.html b/Readme.html new file mode 100644 index 00000000..caf1f6a0 --- /dev/null +++ b/Readme.html @@ -0,0 +1,2808 @@ +<?xml version="1.0" encoding="utf-8" ?> +<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> +<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<head> +<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> +<meta name="generator" content="Docutils 0.9.1: http://docutils.sourceforge.net/" /> +<title>DFHack Readme</title> +<style type="text/css"> + +/* +:Author: David Goodger (goodger@python.org) +:Id: $Id: html4css1.css 7434 2012-05-11 21:06:27Z milde $ +:Copyright: This stylesheet has been placed in the public domain. + +Default cascading style sheet for the HTML output of Docutils. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. +*/ + +/* used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0 } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 ! important } + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 ! important } + +.last, .with-subtitle { + margin-bottom: 0 ! important } + +.hidden { + display: none } + +a.toc-backref { + text-decoration: none ; + color: black } + +blockquote.epigraph { + margin: 2em 5em ; } + +dl.docutils dd { + margin-bottom: 0.5em } + +object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { + overflow: hidden; +} + +/* Uncomment (and remove this text!) to get bold-faced definition list terms +dl.docutils dt { + font-weight: bold } +*/ + +div.abstract { + margin: 2em 5em } + +div.abstract p.topic-title { + font-weight: bold ; + text-align: center } + +div.admonition, div.attention, div.caution, div.danger, div.error, +div.hint, div.important, div.note, div.tip, div.warning { + margin: 2em ; + border: medium outset ; + padding: 1em } + +div.admonition p.admonition-title, div.hint p.admonition-title, +div.important p.admonition-title, div.note p.admonition-title, +div.tip p.admonition-title { + font-weight: bold ; + font-family: sans-serif } + +div.attention p.admonition-title, div.caution p.admonition-title, +div.danger p.admonition-title, div.error p.admonition-title, +div.warning p.admonition-title { + color: red ; + font-weight: bold ; + font-family: sans-serif } + +/* Uncomment (and remove this text!) to get reduced vertical space in + compound paragraphs. +div.compound .compound-first, div.compound .compound-middle { + margin-bottom: 0.5em } + +div.compound .compound-last, div.compound .compound-middle { + margin-top: 0.5em } +*/ + +div.dedication { + margin: 2em 5em ; + text-align: center ; + font-style: italic } + +div.dedication p.topic-title { + font-weight: bold ; + font-style: normal } + +div.figure { + margin-left: 2em ; + margin-right: 2em } + +div.footer, div.header { + clear: both; + font-size: smaller } + +div.line-block { + display: block ; + margin-top: 1em ; + margin-bottom: 1em } + +div.line-block div.line-block { + margin-top: 0 ; + margin-bottom: 0 ; + margin-left: 1.5em } + +div.sidebar { + margin: 0 0 0.5em 1em ; + border: medium outset ; + padding: 1em ; + background-color: #ffffee ; + width: 40% ; + float: right ; + clear: right } + +div.sidebar p.rubric { + font-family: sans-serif ; + font-size: medium } + +div.system-messages { + margin: 5em } + +div.system-messages h1 { + color: red } + +div.system-message { + border: medium outset ; + padding: 1em } + +div.system-message p.system-message-title { + color: red ; + font-weight: bold } + +div.topic { + margin: 2em } + +h1.section-subtitle, h2.section-subtitle, h3.section-subtitle, +h4.section-subtitle, h5.section-subtitle, h6.section-subtitle { + margin-top: 0.4em } + +h1.title { + text-align: center } + +h2.subtitle { + text-align: center } + +hr.docutils { + width: 75% } + +img.align-left, .figure.align-left, object.align-left { + clear: left ; + float: left ; + margin-right: 1em } + +img.align-right, .figure.align-right, object.align-right { + clear: right ; + float: right ; + margin-left: 1em } + +img.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; +} + +.align-left { + text-align: left } + +.align-center { + clear: both ; + text-align: center } + +.align-right { + text-align: right } + +/* reset inner alignment in figures */ +div.align-right { + text-align: inherit } + +/* div.align-center * { */ +/* text-align: left } */ + +ol.simple, ul.simple { + margin-bottom: 1em } + +ol.arabic { + list-style: decimal } + +ol.loweralpha { + list-style: lower-alpha } + +ol.upperalpha { + list-style: upper-alpha } + +ol.lowerroman { + list-style: lower-roman } + +ol.upperroman { + list-style: upper-roman } + +p.attribution { + text-align: right ; + margin-left: 50% } + +p.caption { + font-style: italic } + +p.credits { + font-style: italic ; + font-size: smaller } + +p.label { + white-space: nowrap } + +p.rubric { + font-weight: bold ; + font-size: larger ; + color: maroon ; + text-align: center } + +p.sidebar-title { + font-family: sans-serif ; + font-weight: bold ; + font-size: larger } + +p.sidebar-subtitle { + font-family: sans-serif ; + font-weight: bold } + +p.topic-title { + font-weight: bold } + +pre.address { + margin-bottom: 0 ; + margin-top: 0 ; + font: inherit } + +pre.literal-block, pre.doctest-block, pre.math, pre.code { + margin-left: 2em ; + margin-right: 2em } + +pre.code .ln { /* line numbers */ + color: grey; +} + +.code { + background-color: #eeeeee +} + +span.classifier { + font-family: sans-serif ; + font-style: oblique } + +span.classifier-delimiter { + font-family: sans-serif ; + font-weight: bold } + +span.interpreted { + font-family: sans-serif } + +span.option { + white-space: nowrap } + +span.pre { + white-space: pre } + +span.problematic { + color: red } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80% } + +table.citation { + border-left: solid 1px gray; + margin-left: 1px } + +table.docinfo { + margin: 2em 4em } + +table.docutils { + margin-top: 0.5em ; + margin-bottom: 0.5em } + +table.footnote { + border-left: solid 1px black; + margin-left: 1px } + +table.docutils td, table.docutils th, +table.docinfo td, table.docinfo th { + padding-left: 0.5em ; + padding-right: 0.5em ; + vertical-align: top } + +table.docutils th.field-name, table.docinfo th.docinfo-name { + font-weight: bold ; + text-align: left ; + white-space: nowrap ; + padding-left: 0 } + +h1 tt.docutils, h2 tt.docutils, h3 tt.docutils, +h4 tt.docutils, h5 tt.docutils, h6 tt.docutils { + font-size: 100% } + +ul.auto-toc { + list-style-type: none } + +</style> +</head> +<body> +<div class="document" id="dfhack-readme"> +<h1 class="title">DFHack Readme</h1> + +<div class="section" id="introduction"> +<h1><a class="toc-backref" href="#id2">Introduction</a></h1> +<p>DFHack is a Dwarf Fortress memory access library and a set of basic +tools that use it. Tools come in the form of plugins or (not yet) +external tools. It is an attempt to unite the various ways tools +access DF memory and allow for easier development of new tools.</p> +<div class="contents topic" id="contents"> +<p class="topic-title first">Contents</p> +<ul class="simple"> +<li><a class="reference internal" href="#introduction" id="id2">Introduction</a></li> +<li><a class="reference internal" href="#getting-dfhack" id="id3">Getting DFHack</a></li> +<li><a class="reference internal" href="#compatibility" id="id4">Compatibility</a></li> +<li><a class="reference internal" href="#installation-removal" id="id5">Installation/Removal</a></li> +<li><a class="reference internal" href="#using-dfhack" id="id6">Using DFHack</a></li> +<li><a class="reference internal" href="#something-doesn-t-work-help" id="id7">Something doesn't work, help!</a></li> +<li><a class="reference internal" href="#the-init-file" id="id8">The init file</a><ul> +<li><a class="reference internal" href="#setting-keybindings" id="id9">Setting keybindings</a></li> +</ul> +</li> +<li><a class="reference internal" href="#commands" id="id10">Commands</a><ul> +<li><a class="reference internal" href="#game-progress" id="id11">Game progress</a><ul> +<li><a class="reference internal" href="#die" id="id12">die</a></li> +<li><a class="reference internal" href="#forcepause" id="id13">forcepause</a></li> +<li><a class="reference internal" href="#nopause" id="id14">nopause</a></li> +<li><a class="reference internal" href="#fastdwarf" id="id15">fastdwarf</a></li> +</ul> +</li> +<li><a class="reference internal" href="#game-interface" id="id16">Game interface</a><ul> +<li><a class="reference internal" href="#follow" id="id17">follow</a></li> +<li><a class="reference internal" href="#tidlers" id="id18">tidlers</a></li> +<li><a class="reference internal" href="#twaterlvl" id="id19">twaterlvl</a></li> +<li><a class="reference internal" href="#copystock" id="id20">copystock</a></li> +<li><a class="reference internal" href="#rename" id="id21">rename</a></li> +</ul> +</li> +<li><a class="reference internal" href="#adventure-mode" id="id22">Adventure mode</a><ul> +<li><a class="reference internal" href="#adv-bodyswap" id="id23">adv-bodyswap</a></li> +<li><a class="reference internal" href="#advtools" id="id24">advtools</a></li> +</ul> +</li> +<li><a class="reference internal" href="#map-modification" id="id25">Map modification</a><ul> +<li><a class="reference internal" href="#changelayer" id="id26">changelayer</a></li> +<li><a class="reference internal" href="#changevein" id="id27">changevein</a></li> +<li><a class="reference internal" href="#changeitem" id="id28">changeitem</a></li> +<li><a class="reference internal" href="#colonies" id="id29">colonies</a></li> +<li><a class="reference internal" href="#deramp-by-zilpin" id="id30">deramp (by zilpin)</a></li> +<li><a class="reference internal" href="#feature" id="id31">feature</a></li> +<li><a class="reference internal" href="#liquids" id="id32">liquids</a></li> +<li><a class="reference internal" href="#liquids-here" id="id33">liquids-here</a></li> +<li><a class="reference internal" href="#tiletypes" id="id34">tiletypes</a></li> +<li><a class="reference internal" href="#tiletypes-commands" id="id35">tiletypes-commands</a></li> +<li><a class="reference internal" href="#tiletypes-here" id="id36">tiletypes-here</a></li> +<li><a class="reference internal" href="#tiletypes-here-point" id="id37">tiletypes-here-point</a></li> +<li><a class="reference internal" href="#tubefill" id="id38">tubefill</a></li> +<li><a class="reference internal" href="#extirpate" id="id39">extirpate</a></li> +<li><a class="reference internal" href="#grow" id="id40">grow</a></li> +<li><a class="reference internal" href="#immolate" id="id41">immolate</a></li> +<li><a class="reference internal" href="#regrass" id="id42">regrass</a></li> +<li><a class="reference internal" href="#weather" id="id43">weather</a></li> +</ul> +</li> +<li><a class="reference internal" href="#map-inspection" id="id44">Map inspection</a><ul> +<li><a class="reference internal" href="#cursecheck" id="id45">cursecheck</a></li> +<li><a class="reference internal" href="#flows" id="id46">flows</a></li> +<li><a class="reference internal" href="#probe" id="id47">probe</a></li> +<li><a class="reference internal" href="#prospect" id="id48">prospect</a><ul> +<li><a class="reference internal" href="#pre-embark-estimate" id="id49">Pre-embark estimate</a></li> +</ul> +</li> +<li><a class="reference internal" href="#reveal" id="id50">reveal</a></li> +<li><a class="reference internal" href="#unreveal" id="id51">unreveal</a></li> +<li><a class="reference internal" href="#revtoggle" id="id52">revtoggle</a></li> +<li><a class="reference internal" href="#revflood" id="id53">revflood</a></li> +<li><a class="reference internal" href="#revforget" id="id54">revforget</a></li> +<li><a class="reference internal" href="#showmood" id="id55">showmood</a></li> +</ul> +</li> +<li><a class="reference internal" href="#designations" id="id56">Designations</a><ul> +<li><a class="reference internal" href="#burrow" id="id57">burrow</a></li> +<li><a class="reference internal" href="#digv" id="id58">digv</a></li> +<li><a class="reference internal" href="#digvx" id="id59">digvx</a></li> +<li><a class="reference internal" href="#digl" id="id60">digl</a></li> +<li><a class="reference internal" href="#diglx" id="id61">diglx</a></li> +<li><a class="reference internal" href="#digexp" id="id62">digexp</a></li> +<li><a class="reference internal" href="#digcircle" id="id63">digcircle</a></li> +<li><a class="reference internal" href="#digtype" id="id64">digtype</a></li> +<li><a class="reference internal" href="#filltraffic" id="id65">filltraffic</a></li> +<li><a class="reference internal" href="#alltraffic" id="id66">alltraffic</a></li> +<li><a class="reference internal" href="#getplants" id="id67">getplants</a></li> +</ul> +</li> +<li><a class="reference internal" href="#cleanup-and-garbage-disposal" id="id68">Cleanup and garbage disposal</a><ul> +<li><a class="reference internal" href="#clean" id="id69">clean</a></li> +<li><a class="reference internal" href="#spotclean" id="id70">spotclean</a></li> +<li><a class="reference internal" href="#autodump" id="id71">autodump</a></li> +<li><a class="reference internal" href="#autodump-destroy-here" id="id72">autodump-destroy-here</a></li> +<li><a class="reference internal" href="#autodump-destroy-item" id="id73">autodump-destroy-item</a></li> +<li><a class="reference internal" href="#cleanowned" id="id74">cleanowned</a></li> +</ul> +</li> +<li><a class="reference internal" href="#bugfixes" id="id75">Bugfixes</a><ul> +<li><a class="reference internal" href="#drybuckets" id="id76">drybuckets</a></li> +<li><a class="reference internal" href="#fixdiplomats" id="id77">fixdiplomats</a></li> +<li><a class="reference internal" href="#fixmerchants" id="id78">fixmerchants</a></li> +<li><a class="reference internal" href="#fixveins" id="id79">fixveins</a></li> +<li><a class="reference internal" href="#tweak" id="id80">tweak</a></li> +</ul> +</li> +<li><a class="reference internal" href="#mode-switch-and-reclaim" id="id81">Mode switch and reclaim</a><ul> +<li><a class="reference internal" href="#lair" id="id82">lair</a></li> +<li><a class="reference internal" href="#mode" id="id83">mode</a></li> +</ul> +</li> +<li><a class="reference internal" href="#visualizer-and-data-export" id="id84">Visualizer and data export</a><ul> +<li><a class="reference internal" href="#ssense-stonesense" id="id85">ssense / stonesense</a></li> +<li><a class="reference internal" href="#mapexport" id="id86">mapexport</a></li> +<li><a class="reference internal" href="#dwarfexport" id="id87">dwarfexport</a></li> +</ul> +</li> +<li><a class="reference internal" href="#job-management" id="id88">Job management</a><ul> +<li><a class="reference internal" href="#job" id="id89">job</a></li> +<li><a class="reference internal" href="#job-material" id="id90">job-material</a></li> +<li><a class="reference internal" href="#job-duplicate" id="id91">job-duplicate</a></li> +<li><a class="reference internal" href="#workflow" id="id92">workflow</a><ul> +<li><a class="reference internal" href="#function" id="id93">Function</a></li> +<li><a class="reference internal" href="#constraint-examples" id="id94">Constraint examples</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#fortress-activity-management" id="id95">Fortress activity management</a><ul> +<li><a class="reference internal" href="#seedwatch" id="id96">seedwatch</a></li> +<li><a class="reference internal" href="#zone" id="id97">zone</a><ul> +<li><a class="reference internal" href="#usage-with-single-units" id="id98">Usage with single units</a></li> +<li><a class="reference internal" href="#usage-with-filters" id="id99">Usage with filters</a></li> +<li><a class="reference internal" href="#mass-renaming" id="id100">Mass-renaming</a></li> +<li><a class="reference internal" href="#cage-zones" id="id101">Cage zones</a></li> +<li><a class="reference internal" href="#examples" id="id102">Examples</a></li> +</ul> +</li> +<li><a class="reference internal" href="#autonestbox" id="id103">autonestbox</a></li> +<li><a class="reference internal" href="#autobutcher" id="id104">autobutcher</a></li> +<li><a class="reference internal" href="#autolabor" id="id105">autolabor</a></li> +</ul> +</li> +<li><a class="reference internal" href="#other" id="id106">Other</a><ul> +<li><a class="reference internal" href="#catsplosion" id="id107">catsplosion</a></li> +<li><a class="reference internal" href="#dfusion" id="id108">dfusion</a></li> +<li><a class="reference internal" href="#misery" id="id109">misery</a></li> +</ul> +</li> +</ul> +</li> +<li><a class="reference internal" href="#scripts" id="id110">Scripts</a><ul> +<li><a class="reference internal" href="#fix" id="id111">fix/*</a></li> +<li><a class="reference internal" href="#gui" id="id112">gui/*</a></li> +<li><a class="reference internal" href="#quicksave" id="id113">quicksave</a></li> +<li><a class="reference internal" href="#setfps" id="id114">setfps</a></li> +<li><a class="reference internal" href="#siren" id="id115">siren</a></li> +<li><a class="reference internal" href="#growcrops" id="id116">growcrops</a></li> +<li><a class="reference internal" href="#removebadthoughts" id="id117">removebadthoughts</a></li> +<li><a class="reference internal" href="#slayrace" id="id118">slayrace</a></li> +<li><a class="reference internal" href="#magmasource" id="id119">magmasource</a></li> +<li><a class="reference internal" href="#digfort" id="id120">digfort</a></li> +<li><a class="reference internal" href="#superdwarf" id="id121">superdwarf</a></li> +<li><a class="reference internal" href="#drainaquifer" id="id122">drainaquifer</a></li> +<li><a class="reference internal" href="#deathcause" id="id123">deathcause</a></li> +</ul> +</li> +<li><a class="reference internal" href="#in-game-interface-tools" id="id124">In-game interface tools</a><ul> +<li><a class="reference internal" href="#dwarf-manipulator" id="id125">Dwarf Manipulator</a></li> +<li><a class="reference internal" href="#gui-liquids" id="id126">gui/liquids</a></li> +<li><a class="reference internal" href="#gui-mechanisms" id="id127">gui/mechanisms</a></li> +<li><a class="reference internal" href="#gui-rename" id="id128">gui/rename</a></li> +<li><a class="reference internal" href="#gui-room-list" id="id129">gui/room-list</a></li> +<li><a class="reference internal" href="#gui-choose-weapons" id="id130">gui/choose-weapons</a></li> +</ul> +</li> +<li><a class="reference internal" href="#behavior-mods" id="id131">Behavior Mods</a><ul> +<li><a class="reference internal" href="#siege-engine" id="id132">Siege Engine</a><ul> +<li><a class="reference internal" href="#rationale" id="id133">Rationale</a></li> +<li><a class="reference internal" href="#configuration-ui" id="id134">Configuration UI</a></li> +</ul> +</li> +<li><a class="reference internal" href="#power-meter" id="id135">Power Meter</a></li> +<li><a class="reference internal" href="#steam-engine" id="id136">Steam Engine</a><ul> +<li><a class="reference internal" href="#id1" id="id137">Rationale</a></li> +<li><a class="reference internal" href="#construction" id="id138">Construction</a></li> +<li><a class="reference internal" href="#operation" id="id139">Operation</a></li> +<li><a class="reference internal" href="#explosions" id="id140">Explosions</a></li> +<li><a class="reference internal" href="#save-files" id="id141">Save files</a></li> +</ul> +</li> +<li><a class="reference internal" href="#add-spatter" id="id142">Add Spatter</a></li> +</ul> +</li> +</ul> +</div> +</div> +<div class="section" id="getting-dfhack"> +<h1><a class="toc-backref" href="#id3">Getting DFHack</a></h1> +<p>The project is currently hosted on <a class="reference external" href="http://www.github.com/">github</a>, for both source and +binaries at <a class="reference external" href="http://github.com/peterix/dfhack">http://github.com/peterix/dfhack</a></p> +<p>Releases can be downloaded from here: <a class="reference external" href="https://github.com/peterix/dfhack/downloads">https://github.com/peterix/dfhack/downloads</a></p> +<p>All new releases are announced in the bay12 thread: <a class="reference external" href="http://tinyurl.com/dfhack-ng">http://tinyurl.com/dfhack-ng</a></p> +</div> +<div class="section" id="compatibility"> +<h1><a class="toc-backref" href="#id4">Compatibility</a></h1> +<p>DFHack works on Windows XP, Vista, 7 or any modern Linux distribution. +OSX is not supported due to lack of developers with a Mac.</p> +<p>Currently, version 0.34.11 is supported (and tested). If you need DFHack +for older versions, look for older releases.</p> +<p>On Windows, you have to use the SDL version of DF.</p> +<p>It is possible to use the Windows DFHack under wine/OSX.</p> +</div> +<div class="section" id="installation-removal"> +<h1><a class="toc-backref" href="#id5">Installation/Removal</a></h1> +<p>Installing DFhack involves copying files into your DF folder. +Copy the files from a release archive so that:</p> +<blockquote> +<ul class="simple"> +<li>On Windows, SDL.dll is replaced</li> +<li>On Linux, the 'dfhack' script is placed in the same folder as the 'df' script</li> +</ul> +</blockquote> +<p>Uninstalling is basically the same, in reverse:</p> +<blockquote> +<ul class="simple"> +<li>On Windows, first delete SDL.dll and rename SDLreal.dll to SDL.dll. Then +remove the other DFHack files</li> +<li>On Linux, Remove the DFHack files.</li> +</ul> +</blockquote> +<p>The stonesense plugin might require some additional libraries on Linux.</p> +<p>If any of the plugins or dfhack itself refuses to load, check the stderr.log +file created in your DF folder.</p> +</div> +<div class="section" id="using-dfhack"> +<h1><a class="toc-backref" href="#id6">Using DFHack</a></h1> +<p>DFHack basically extends what DF can do with something similar to the drop-down +console found in Quake engine games. On Windows, this is a separate command line +window. On linux, the terminal used to launch the dfhack script is taken over +(so, make sure you start from a terminal). Basic interaction with dfhack +involves entering commands into the console. For some basic instroduction, +use the 'help' command. To list all possible commands, use the 'ls' command. +Many commands have their own help or detailed description. You can use +'command help' or 'command ?' to show that.</p> +<p>The command line has some nice line editing capabilities, including history +that's preserved between different runs of DF (use up/down keys to go through +the history).</p> +<p>The second way to interact with DFHack is to bind the available commands +to in-game hotkeys. The old way to do this is via the hotkey/zoom menu (normally +opened with the 'h' key). Binding the commands is done by assigning a command as +a hotkey name (with 'n').</p> +<p>A new and more flexible way is the keybinding command in the dfhack console. +However, bindings created this way are not automatically remembered between runs +of the game, so it becomes necessary to use the dfhack.init file to ensure that +they are re-created every time it is loaded.</p> +<p>Interactive commands like 'liquids' cannot be used as hotkeys.</p> +<p>Most of the commands come from plugins. Those reside in 'hack/plugins/'.</p> +</div> +<div class="section" id="something-doesn-t-work-help"> +<h1><a class="toc-backref" href="#id7">Something doesn't work, help!</a></h1> +<p>First, don't panic :) Second, dfhack keeps a few log files in DF's folder +- stderr.log and stdout.log. You can look at those and possibly find out what's +happening. +If you found a bug, you can either report it in the bay12 DFHack thread, +the issues tracker on github, contact me (<a class="reference external" href="mailto:peterix@gmail.com">peterix@gmail.com</a>) or visit the +#dfhack IRC channel on freenode.</p> +</div> +<div class="section" id="the-init-file"> +<h1><a class="toc-backref" href="#id8">The init file</a></h1> +<p>If your DF folder contains a file named <tt class="docutils literal">dfhack.init</tt>, its contents will be run +every time you start DF. This allows setting up keybindings. An example file +is provided as <tt class="docutils literal"><span class="pre">dfhack.init-example</span></tt> - you can tweak it and rename to dfhack.init +if you want to use this functionality.</p> +<div class="section" id="setting-keybindings"> +<h2><a class="toc-backref" href="#id9">Setting keybindings</a></h2> +<p>To set keybindings, use the built-in <tt class="docutils literal">keybinding</tt> command. Like any other +command it can be used at any time from the console, but it is also meaningful +in the DFHack init file.</p> +<p>Currently it supports any combination of Ctrl/Alt/Shift with F1-F9, or A-Z.</p> +<p>Possible ways to call the command:</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name" colspan="2">keybinding list <key>:</th></tr> +<tr class="field"><td> </td><td class="field-body">List bindings active for the key combination.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">keybinding clear <key> <key>...:</th></tr> +<tr class="field"><td> </td><td class="field-body">Remove bindings for the specified keys.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">keybinding add <key> "cmdline" "cmdline"...:</th></tr> +<tr class="field"><td> </td><td class="field-body">Add bindings for the specified +key.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">keybinding set <key> "cmdline" "cmdline"...:</th></tr> +<tr class="field"><td> </td><td class="field-body">Clear, and then add bindings for +the specified key.</td> +</tr> +</tbody> +</table> +<p>The <em><key></em> parameter above has the following <em>case-sensitive</em> syntax:</p> +<pre class="literal-block"> +[Ctrl-][Alt-][Shift-]KEY[@context] +</pre> +<p>where the <em>KEY</em> part can be F1-F9 or A-Z, and [] denote optional parts.</p> +<p>When multiple commands are bound to the same key combination, DFHack selects +the first applicable one. Later 'add' commands, and earlier entries within one +'add' command have priority. Commands that are not specifically intended for use +as a hotkey are always considered applicable.</p> +<p>The <em>context</em> part in the key specifier above can be used to explicitly restrict +the UI state where the binding would be applicable. If called without parameters, +the <tt class="docutils literal">keybinding</tt> command among other things prints the current context string. +Only bindings with a <em>context</em> tag that either matches the current context fully, +or is a prefix ending at a '/' boundary would be considered for execution, i.e. +for context <tt class="docutils literal">foo/bar/baz</tt>, possible matches are any of <tt class="docutils literal">@foo/bar/baz</tt>, <tt class="docutils literal">@foo/bar</tt>, +<tt class="docutils literal">@foo</tt> or none.</p> +</div> +</div> +<div class="section" id="commands"> +<h1><a class="toc-backref" href="#id10">Commands</a></h1> +<p>DFHack command syntax consists of a command name, followed by arguments separated +by whitespace. To include whitespace in an argument, quote it in double quotes. +To include a double quote character, use <tt class="docutils literal">\"</tt> inside double quotes.</p> +<p>If the first non-whitespace character of a line is <tt class="docutils literal">#</tt>, the line is treated +as a comment, i.e. a silent no-op command.</p> +<p>If the first non-whitespace character is <tt class="docutils literal">:</tt>, the command is parsed in a special +alternative mode: first, non-whitespace characters immediately following the <tt class="docutils literal">:</tt> +are used as the command name; the remaining part of the line, starting with the first +non-whitespace character <em>after</em> the command name, is used verbatim as the first argument. +The following two command lines are exactly equivalent:</p> +<blockquote> +<ul class="simple"> +<li><tt class="docutils literal">:foo a b "c d" e f</tt></li> +<li><tt class="docutils literal">foo "a b \"c d\" e f"</tt></li> +</ul> +</blockquote> +<p>This is intended for commands like <tt class="docutils literal">rb_eval</tt> that evaluate script language statements.</p> +<p>Almost all the commands support using the 'help <command-name>' built-in command +to retrieve further help without having to look at this document. Alternatively, +some accept a 'help'/'?' option on their command line.</p> +<div class="section" id="game-progress"> +<h2><a class="toc-backref" href="#id11">Game progress</a></h2> +<div class="section" id="die"> +<h3><a class="toc-backref" href="#id12">die</a></h3> +<p>Instantly kills DF without saving.</p> +</div> +<div class="section" id="forcepause"> +<h3><a class="toc-backref" href="#id13">forcepause</a></h3> +<p>Forces DF to pause. This is useful when your FPS drops below 1 and you lose +control of the game.</p> +<blockquote> +<ul class="simple"> +<li>Activate with 'forcepause 1'</li> +<li>Deactivate with 'forcepause 0'</li> +</ul> +</blockquote> +</div> +<div class="section" id="nopause"> +<h3><a class="toc-backref" href="#id14">nopause</a></h3> +<p>Disables pausing (both manual and automatic) with the exception of pause forced +by 'reveal hell'. This is nice for digging under rivers.</p> +</div> +<div class="section" id="fastdwarf"> +<h3><a class="toc-backref" href="#id15">fastdwarf</a></h3> +<p>Controls speedydwarf and teledwarf. Speedydwarf makes dwarves move quickly and perform tasks quickly. Teledwarf makes dwarves move instantaneously, but do jobs at the same speed.</p> +<blockquote> +<ul class="simple"> +<li>'fastdwarf 0 0' disables both</li> +<li>'fastdwarf 0 1' disables speedydwarf and enables teledwarf</li> +<li>'fastdwarf 1 0' enables speedydwarf and disables teledwarf</li> +<li>'fastdwarf 1 1' enables both</li> +<li>'fastdwarf 0' disables both</li> +<li>'fastdwarf 1' enables speedydwarf and disables teledwarf</li> +</ul> +</blockquote> +</div> +</div> +<div class="section" id="game-interface"> +<h2><a class="toc-backref" href="#id16">Game interface</a></h2> +<div class="section" id="follow"> +<h3><a class="toc-backref" href="#id17">follow</a></h3> +<p>Makes the game view follow the currently highlighted unit after you exit from +current menu/cursor mode. Handy for watching dwarves running around. Deactivated +by moving the view manually.</p> +</div> +<div class="section" id="tidlers"> +<h3><a class="toc-backref" href="#id18">tidlers</a></h3> +<p>Toggle between all possible positions where the idlers count can be placed.</p> +</div> +<div class="section" id="twaterlvl"> +<h3><a class="toc-backref" href="#id19">twaterlvl</a></h3> +<p>Toggle between displaying/not displaying liquid depth as numbers.</p> +</div> +<div class="section" id="copystock"> +<h3><a class="toc-backref" href="#id20">copystock</a></h3> +<p>Copies the parameters of the currently highlighted stockpile to the custom +stockpile settings and switches to custom stockpile placement mode, effectively +allowing you to copy/paste stockpiles easily.</p> +</div> +<div class="section" id="rename"> +<h3><a class="toc-backref" href="#id21">rename</a></h3> +<p>Allows renaming various things.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name" colspan="2">rename squad <index> "name":</th></tr> +<tr class="field"><td> </td><td class="field-body">Rename squad by index to 'name'.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">rename hotkey <index> "name":</th></tr> +<tr class="field"><td> </td><td class="field-body">Rename hotkey by index. This allows assigning +longer commands to the DF hotkeys.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">rename unit "nickname":</th></tr> +<tr class="field"><td> </td><td class="field-body">Rename a unit/creature highlighted in the DF user +interface.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">rename unit-profession "custom profession":</th></tr> +<tr class="field"><td> </td><td class="field-body">Change proffession name of the +highlighted unit/creature.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">rename building "name":</th></tr> +<tr class="field"><td> </td><td class="field-body">Set a custom name for the selected building. +The building must be one of stockpile, workshop, furnace, trap, +siege engine or an activity zone.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +</div> +<div class="section" id="adventure-mode"> +<h2><a class="toc-backref" href="#id22">Adventure mode</a></h2> +<div class="section" id="adv-bodyswap"> +<h3><a class="toc-backref" href="#id23">adv-bodyswap</a></h3> +<p>This allows taking control over your followers and other creatures in adventure +mode. For example, you can make them pick up new arms and armor and equip them +properly.</p> +<p>Usage:</p> +<blockquote> +<ul class="simple"> +<li>When viewing unit details, body-swaps into that unit.</li> +<li>In the main adventure mode screen, reverts transient swap.</li> +</ul> +</blockquote> +</div> +<div class="section" id="advtools"> +<h3><a class="toc-backref" href="#id24">advtools</a></h3> +<p>A package of different adventure mode tools (currently just one)</p> +<p>Usage:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name" colspan="2">list-equipped [all]:</th></tr> +<tr class="field"><td> </td><td class="field-body">List armor and weapons equipped by your companions. +If all is specified, also lists non-metal clothing.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">metal-detector [all-types] [non-trader]:</th></tr> +<tr class="field"><td> </td><td class="field-body">Reveal metal armor and weapons in +shops. The options disable the checks +on item type and being in shop.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +</div> +<div class="section" id="map-modification"> +<h2><a class="toc-backref" href="#id25">Map modification</a></h2> +<div class="section" id="changelayer"> +<h3><a class="toc-backref" href="#id26">changelayer</a></h3> +<p>Changes material of the geology layer under cursor to the specified inorganic +RAW material. Can have impact on all surrounding regions, not only your embark! +By default changing stone to soil and vice versa is not allowed. By default +changes only the layer at the cursor position. Note that one layer can stretch +across lots of z levels. By default changes only the geology which is linked +to the biome under the cursor. That geology might be linked to other biomes +as well, though. Mineral veins and gem clusters will stay on the map. Use +'changevein' for them.</p> +<p>tl;dr: You will end up with changing quite big areas in one go, especially if +you use it in lower z levels. Use with care.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">all_biomes:</th><td class="field-body">Change selected layer for all biomes on your map. +Result may be undesirable since the same layer can AND WILL +be on different z-levels for different biomes. Use the tool +'probe' to get an idea how layers and biomes are distributed +on your map.</td> +</tr> +<tr class="field"><th class="field-name">all_layers:</th><td class="field-body">Change all layers on your map (only for the selected biome +unless 'all_biomes' is added). +Candy mountain, anyone? Will make your map quite boring, +but tidy.</td> +</tr> +<tr class="field"><th class="field-name">force:</th><td class="field-body">Allow changing stone to soil and vice versa. !!THIS CAN HAVE +WEIRD EFFECTS, USE WITH CARE!! +Note that soil will not be magically replaced with stone. +You will, however, get a stone floor after digging so it +will allow the floor to be engraved. +Note that stone will not be magically replaced with soil. +You will, however, get a soil floor after digging so it +could be helpful for creating farm plots on maps with no +soil.</td> +</tr> +<tr class="field"><th class="field-name">verbose:</th><td class="field-body">Give some details about what is being changed.</td> +</tr> +<tr class="field"><th class="field-name">trouble:</th><td class="field-body">Give some advice about known problems.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Examples:</p> +<blockquote> +<dl class="docutils"> +<dt><tt class="docutils literal">changelayer GRANITE</tt></dt> +<dd>Convert layer at cursor position into granite.</dd> +<dt><tt class="docutils literal">changelayer SILTY_CLAY force</tt></dt> +<dd>Convert layer at cursor position into clay even if it's stone.</dd> +<dt><tt class="docutils literal">changelayer MARBLE all_biomes all_layers</tt></dt> +<dd>Convert all layers of all biomes which are not soil into marble.</dd> +</dl> +</blockquote> +<div class="note"> +<p class="first admonition-title">Note</p> +<ul class="last simple"> +<li>If you use changelayer and nothing happens, try to pause/unpause the game +for a while and try to move the cursor to another tile. Then try again. +If that doesn't help try temporarily changing some other layer, undo your +changes and try again for the layer you want to change. Saving +and reloading your map might also help.</li> +<li>You should be fine if you only change single layers without the use +of 'force'. Still it's advisable to save your game before messing with +the map.</li> +<li>When you force changelayer to convert soil to stone you might experience +weird stuff (flashing tiles, tiles changed all over place etc). +Try reverting the changes manually or even better use an older savegame. +You did save your game, right?</li> +</ul> +</div> +</div> +<div class="section" id="changevein"> +<h3><a class="toc-backref" href="#id27">changevein</a></h3> +<p>Changes material of the vein under cursor to the specified inorganic RAW +material. Only affects tiles within the current 16x16 block - for veins and +large clusters, you will need to use this command multiple times.</p> +<p>Example:</p> +<blockquote> +<dl class="docutils"> +<dt><tt class="docutils literal">changevein NATIVE_PLATINUM</tt></dt> +<dd>Convert vein at cursor position into platinum ore.</dd> +</dl> +</blockquote> +</div> +<div class="section" id="changeitem"> +<h3><a class="toc-backref" href="#id28">changeitem</a></h3> +<p>Allows changing item material and base quality. By default the item currently +selected in the UI will be changed (you can select items in the 'k' list +or inside containers/inventory). By default change is only allowed if materials +is of the same subtype (for example wood<->wood, stone<->stone etc). But since +some transformations work pretty well and may be desired you can override this +with 'force'. Note that some attributes will not be touched, possibly resulting +in weirdness. To get an idea how the RAW id should look like, check some items +with 'info'. Using 'force' might create items which are not touched by +crafters/haulers.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">info:</th><td class="field-body">Don't change anything, print some info instead.</td> +</tr> +<tr class="field"><th class="field-name">here:</th><td class="field-body">Change all items at the cursor position. Requires in-game cursor.</td> +</tr> +<tr class="field"><th class="field-name">material, m:</th><td class="field-body">Change material. Must be followed by valid material RAW id.</td> +</tr> +<tr class="field"><th class="field-name">quality, q:</th><td class="field-body">Change base quality. Must be followed by number (0-5).</td> +</tr> +<tr class="field"><th class="field-name">force:</th><td class="field-body">Ignore subtypes, force change to new material.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Examples:</p> +<blockquote> +<dl class="docutils"> +<dt><tt class="docutils literal">changeitem m INORGANIC:GRANITE here</tt></dt> +<dd>Change material of all items under the cursor to granite.</dd> +<dt><tt class="docutils literal">changeitem q 5</tt></dt> +<dd>Change currently selected item to masterpiece quality.</dd> +</dl> +</blockquote> +</div> +<div class="section" id="colonies"> +<h3><a class="toc-backref" href="#id29">colonies</a></h3> +<p>Allows listing all the vermin colonies on the map and optionally turning them into honey bee colonies.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">bees:</th><td class="field-body">turn colonies into honey bee colonies</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="deramp-by-zilpin"> +<h3><a class="toc-backref" href="#id30">deramp (by zilpin)</a></h3> +<p>Removes all ramps designated for removal from the map. This is useful for replicating the old channel digging designation. +It also removes any and all 'down ramps' that can remain after a cave-in (you don't have to designate anything for that to happen).</p> +</div> +<div class="section" id="feature"> +<h3><a class="toc-backref" href="#id31">feature</a></h3> +<p>Enables management of map features.</p> +<ul class="simple"> +<li>Discovering a magma feature (magma pool, volcano, magma sea, or curious +underground structure) permits magma workshops and furnaces to be built.</li> +<li>Discovering a cavern layer causes plants (trees, shrubs, and grass) from +that cavern to grow within your fortress.</li> +</ul> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">list:</th><td class="field-body">Lists all map features in your current embark by index.</td> +</tr> +<tr class="field"><th class="field-name">show X:</th><td class="field-body">Marks the selected map feature as discovered.</td> +</tr> +<tr class="field"><th class="field-name">hide X:</th><td class="field-body">Marks the selected map feature as undiscovered.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="liquids"> +<h3><a class="toc-backref" href="#id32">liquids</a></h3> +<p>Allows adding magma, water and obsidian to the game. It replaces the normal +dfhack command line and can't be used from a hotkey. Settings will be remembered +as long as dfhack runs. Intended for use in combination with the command +liquids-here (which can be bound to a hotkey).</p> +<p>For more information, refer to the command's internal help.</p> +<div class="note"> +<p class="first admonition-title">Note</p> +<p class="last">Spawning and deleting liquids can F up pathing data and +temperatures (creating heat traps). You've been warned.</p> +</div> +</div> +<div class="section" id="liquids-here"> +<h3><a class="toc-backref" href="#id33">liquids-here</a></h3> +<p>Run the liquid spawner with the current/last settings made in liquids (if no +settings in liquids were made it paints a point of 7/7 magma by default).</p> +<p>Intended to be used as keybinding. Requires an active in-game cursor.</p> +</div> +<div class="section" id="tiletypes"> +<h3><a class="toc-backref" href="#id34">tiletypes</a></h3> +<p>Can be used for painting map tiles and is an interactive command, much like +liquids.</p> +<p>The tool works with two set of options and a brush. The brush determines which +tiles will be processed. First set of options is the filter, which can exclude +some of the tiles from the brush by looking at the tile properties. The second +set of options is the paint - this determines how the selected tiles are +changed.</p> +<p>Both paint and filter can have many different properties including things like +general shape (WALL, FLOOR, etc.), general material (SOIL, STONE, MINERAL, +etc.), state of 'designated', 'hidden' and 'light' flags.</p> +<p>The properties of filter and paint can be partially defined. This means that +you can for example do something like this:</p> +<pre class="literal-block"> +filter material STONE +filter shape FORTIFICATION +paint shape FLOOR +</pre> +<p>This will turn all stone fortifications into floors, preserving the material.</p> +<p>Or this:</p> +<pre class="literal-block"> +filter shape FLOOR +filter material MINERAL +paint shape WALL +</pre> +<p>Turning mineral vein floors back into walls.</p> +<p>The tool also allows tweaking some tile flags:</p> +<p>Or this:</p> +<pre class="literal-block"> +paint hidden 1 +paint hidden 0 +</pre> +<p>This will hide previously revealed tiles (or show hidden with the 0 option).</p> +<p>Any paint or filter option (or the entire paint or filter) can be disabled entirely by using the ANY keyword:</p> +<pre class="literal-block"> +paint hidden ANY +paint shape ANY +filter material any +filter shape any +filter any +</pre> +<dl class="docutils"> +<dt>You can use several different brushes for painting tiles:</dt> +<dd><ul class="first last simple"> +<li>Point. (point)</li> +<li>Rectangular range. (range)</li> +<li>A column ranging from current cursor to the first solid tile above. (column)</li> +<li>DF map block - 16x16 tiles, in a regular grid. (block)</li> +</ul> +</dd> +</dl> +<p>Example:</p> +<pre class="literal-block"> +range 10 10 1 +</pre> +<p>This will change the brush to a rectangle spanning 10x10 tiles on one z-level. +The range starts at the position of the cursor and goes to the east, south and +up.</p> +<p>For more details, see the 'help' command while using this.</p> +</div> +<div class="section" id="tiletypes-commands"> +<h3><a class="toc-backref" href="#id35">tiletypes-commands</a></h3> +<p>Runs tiletypes commands, separated by ;. This makes it possible to change +tiletypes modes from a hotkey.</p> +</div> +<div class="section" id="tiletypes-here"> +<h3><a class="toc-backref" href="#id36">tiletypes-here</a></h3> +<p>Apply the current tiletypes options at the in-game cursor position, including +the brush. Can be used from a hotkey.</p> +</div> +<div class="section" id="tiletypes-here-point"> +<h3><a class="toc-backref" href="#id37">tiletypes-here-point</a></h3> +<p>Apply the current tiletypes options at the in-game cursor position to a single +tile. Can be used from a hotkey.</p> +</div> +<div class="section" id="tubefill"> +<h3><a class="toc-backref" href="#id38">tubefill</a></h3> +<p>Fills all the adamantine veins again. Veins that were empty will be filled in +too, but might still trigger a demon invasion (this is a known bug).</p> +</div> +<div class="section" id="extirpate"> +<h3><a class="toc-backref" href="#id39">extirpate</a></h3> +<p>A tool for getting rid of trees and shrubs. By default, it only kills +a tree/shrub under the cursor. The plants are turned into ashes instantly.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">shrubs:</th><td class="field-body">affect all shrubs on the map</td> +</tr> +<tr class="field"><th class="field-name">trees:</th><td class="field-body">affect all trees on the map</td> +</tr> +<tr class="field"><th class="field-name">all:</th><td class="field-body">affect every plant!</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="grow"> +<h3><a class="toc-backref" href="#id40">grow</a></h3> +<p>Makes all saplings present on the map grow into trees (almost) instantly.</p> +</div> +<div class="section" id="immolate"> +<h3><a class="toc-backref" href="#id41">immolate</a></h3> +<p>Very similar to extirpate, but additionally sets the plants on fire. The fires +can and <em>will</em> spread ;)</p> +</div> +<div class="section" id="regrass"> +<h3><a class="toc-backref" href="#id42">regrass</a></h3> +<p>Regrows grass. Not much to it ;)</p> +</div> +<div class="section" id="weather"> +<h3><a class="toc-backref" href="#id43">weather</a></h3> +<p>Prints the current weather map by default.</p> +<p>Also lets you change the current weather to 'clear sky', 'rainy' or 'snowing'.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">snow:</th><td class="field-body">make it snow everywhere.</td> +</tr> +<tr class="field"><th class="field-name">rain:</th><td class="field-body">make it rain.</td> +</tr> +<tr class="field"><th class="field-name">clear:</th><td class="field-body">clear the sky.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +</div> +<div class="section" id="map-inspection"> +<h2><a class="toc-backref" href="#id44">Map inspection</a></h2> +<div class="section" id="cursecheck"> +<h3><a class="toc-backref" href="#id45">cursecheck</a></h3> +<p>Checks a single map tile or the whole map/world for cursed creatures (ghosts, +vampires, necromancers, werebeasts, zombies).</p> +<p>With an active in-game cursor only the selected tile will be observed. +Without a cursor the whole map will be checked.</p> +<p>By default cursed creatures will be only counted in case you just want to find +out if you have any of them running around in your fort. Dead and passive +creatures (ghosts who were put to rest, killed vampires, ...) are ignored. +Undead skeletons, corpses, bodyparts and the like are all thrown into the curse +category "zombie". Anonymous zombies and resurrected body parts will show +as "unnamed creature".</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">detail:</th><td class="field-body">Print full name, date of birth, date of curse and some status +info (some vampires might use fake identities in-game, though).</td> +</tr> +<tr class="field"><th class="field-name">nick:</th><td class="field-body">Set the type of curse as nickname (does not always show up +in-game, some vamps don't like nicknames).</td> +</tr> +<tr class="field"><th class="field-name">all:</th><td class="field-body">Include dead and passive cursed creatures (can result in a quite +long list after having FUN with necromancers).</td> +</tr> +<tr class="field"><th class="field-name">verbose:</th><td class="field-body">Print all curse tags (if you really want to know it all).</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Examples:</p> +<blockquote> +<dl class="docutils"> +<dt><tt class="docutils literal">cursecheck detail all</tt></dt> +<dd>Give detailed info about all cursed creatures including deceased ones (no +in-game cursor).</dd> +<dt><tt class="docutils literal">cursecheck nick</tt></dt> +<dd>Give a nickname all living/active cursed creatures on the map(no in-game +cursor).</dd> +</dl> +</blockquote> +<div class="note"> +<p class="first admonition-title">Note</p> +<ul class="last simple"> +<li>If you do a full search (with the option "all") former ghosts will show up +with the cursetype "unknown" because their ghostly flag is not set +anymore. But if you happen to find a living/active creature with cursetype +"unknown" please report that in the dfhack thread on the modding forum or +per irc. This is likely to happen with mods which introduce new types +of curses, for example.</li> +</ul> +</div> +</div> +<div class="section" id="flows"> +<h3><a class="toc-backref" href="#id46">flows</a></h3> +<p>A tool for checking how many tiles contain flowing liquids. If you suspect that +your magma sea leaks into HFS, you can use this tool to be sure without +revealing the map.</p> +</div> +<div class="section" id="probe"> +<h3><a class="toc-backref" href="#id47">probe</a></h3> +<p>Can be used to determine tile properties like temperature.</p> +</div> +<div class="section" id="prospect"> +<h3><a class="toc-backref" href="#id48">prospect</a></h3> +<p>Prints a big list of all the present minerals and plants. By default, only +the visible part of the map is scanned.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">all:</th><td class="field-body">Scan the whole map, as if it was revealed.</td> +</tr> +<tr class="field"><th class="field-name">value:</th><td class="field-body">Show material value in the output. Most useful for gems.</td> +</tr> +<tr class="field"><th class="field-name">hell:</th><td class="field-body">Show the Z range of HFS tubes. Implies 'all'.</td> +</tr> +</tbody> +</table> +</blockquote> +<div class="section" id="pre-embark-estimate"> +<h4><a class="toc-backref" href="#id49">Pre-embark estimate</a></h4> +<p>If prospect is called during the embark selection screen, it displays an estimate of +layer stone availability.</p> +<div class="note"> +<p class="first admonition-title">Note</p> +<p class="last">The results of pre-embark prospect are an <em>estimate</em>, and can at best be expected +to be somewhere within +/- 30% of the true amount; sometimes it does a lot worse. +Especially, it is not clear how to precisely compute how many soil layers there +will be in a given embark tile, so it can report a whole extra layer, or omit one +that is actually present.</p> +</div> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">all:</th><td class="field-body">Also estimate vein mineral amounts.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +</div> +<div class="section" id="reveal"> +<h3><a class="toc-backref" href="#id50">reveal</a></h3> +<p>This reveals the map. By default, HFS will remain hidden so that the demons +don't spawn. You can use 'reveal hell' to reveal everything. With hell revealed, +you won't be able to unpause until you hide the map again. If you really want +to unpause with hell revealed, use 'reveal demons'.</p> +<p>Reveal also works in adventure mode, but any of its effects are negated once +you move. When you use it this way, you don't need to run 'unreveal'.</p> +</div> +<div class="section" id="unreveal"> +<h3><a class="toc-backref" href="#id51">unreveal</a></h3> +<p>Reverts the effects of 'reveal'.</p> +</div> +<div class="section" id="revtoggle"> +<h3><a class="toc-backref" href="#id52">revtoggle</a></h3> +<p>Switches between 'reveal' and 'unreveal'.</p> +</div> +<div class="section" id="revflood"> +<h3><a class="toc-backref" href="#id53">revflood</a></h3> +<p>This command will hide the whole map and then reveal all the tiles that have +a path to the in-game cursor.</p> +</div> +<div class="section" id="revforget"> +<h3><a class="toc-backref" href="#id54">revforget</a></h3> +<p>When you use reveal, it saves information about what was/wasn't visible before +revealing everything. Unreveal uses this information to hide things again. +This command throws away the information. For example, use in cases where +you abandoned with the fort revealed and no longer want the data.</p> +</div> +<div class="section" id="showmood"> +<h3><a class="toc-backref" href="#id55">showmood</a></h3> +<p>Shows all items needed for the currently active strange mood.</p> +</div> +</div> +<div class="section" id="designations"> +<h2><a class="toc-backref" href="#id56">Designations</a></h2> +<div class="section" id="burrow"> +<h3><a class="toc-backref" href="#id57">burrow</a></h3> +<p>Miscellaneous burrow control. Allows manipulating burrows and automated burrow +expansion while digging.</p> +<p>Options:</p> +<blockquote> +<dl class="docutils"> +<dt><strong>enable feature ...</strong></dt> +<dd>Enable features of the plugin.</dd> +<dt><strong>disable feature ...</strong></dt> +<dd>Disable features of the plugin.</dd> +<dt><strong>clear-unit burrow burrow ...</strong></dt> +<dd>Remove all units from the burrows.</dd> +<dt><strong>clear-tiles burrow burrow ...</strong></dt> +<dd>Remove all tiles from the burrows.</dd> +<dt><strong>set-units target-burrow src-burrow ...</strong></dt> +<dd>Clear target, and adds units from source burrows.</dd> +<dt><strong>add-units target-burrow src-burrow ...</strong></dt> +<dd>Add units from the source burrows to the target.</dd> +<dt><strong>remove-units target-burrow src-burrow ...</strong></dt> +<dd>Remove units in source burrows from the target.</dd> +<dt><strong>set-tiles target-burrow src-burrow ...</strong></dt> +<dd>Clear target and adds tiles from the source burrows.</dd> +<dt><strong>add-tiles target-burrow src-burrow ...</strong></dt> +<dd>Add tiles from the source burrows to the target.</dd> +<dt><strong>remove-tiles target-burrow src-burrow ...</strong></dt> +<dd><p class="first">Remove tiles in source burrows from the target.</p> +<p class="last">For these three options, in place of a source burrow it is +possible to use one of the following keywords: ABOVE_GROUND, +SUBTERRANEAN, INSIDE, OUTSIDE, LIGHT, DARK, HIDDEN, REVEALED</p> +</dd> +</dl> +</blockquote> +<p>Features:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">auto-grow:</th><td class="field-body">When a wall inside a burrow with a name ending in '+' is dug +out, the burrow is extended to newly-revealed adjacent walls. +This final '+' may be omitted in burrow name args of commands above. +Digging 1-wide corridors with the miner inside the burrow is SLOW.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="digv"> +<h3><a class="toc-backref" href="#id58">digv</a></h3> +<p>Designates a whole vein for digging. Requires an active in-game cursor placed +over a vein tile. With the 'x' option, it will traverse z-levels (putting stairs +between the same-material tiles).</p> +</div> +<div class="section" id="digvx"> +<h3><a class="toc-backref" href="#id59">digvx</a></h3> +<p>A permanent alias for 'digv x'.</p> +</div> +<div class="section" id="digl"> +<h3><a class="toc-backref" href="#id60">digl</a></h3> +<p>Designates layer stone for digging. Requires an active in-game cursor placed +over a layer stone tile. With the 'x' option, it will traverse z-levels +(putting stairs between the same-material tiles). With the 'undo' option it +will remove the dig designation instead (if you realize that digging out a 50 +z-level deep layer was not such a good idea after all).</p> +</div> +<div class="section" id="diglx"> +<h3><a class="toc-backref" href="#id61">diglx</a></h3> +<p>A permanent alias for 'digl x'.</p> +</div> +<div class="section" id="digexp"> +<h3><a class="toc-backref" href="#id62">digexp</a></h3> +<p>This command can be used for exploratory mining.</p> +<p>See: <a class="reference external" href="http://df.magmawiki.com/index.php/DF2010:Exploratory_mining">http://df.magmawiki.com/index.php/DF2010:Exploratory_mining</a></p> +<p>There are two variables that can be set: pattern and filter.</p> +<p>Patterns:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">diag5:</th><td class="field-body">diagonals separated by 5 tiles</td> +</tr> +<tr class="field"><th class="field-name">diag5r:</th><td class="field-body">diag5 rotated 90 degrees</td> +</tr> +<tr class="field"><th class="field-name">ladder:</th><td class="field-body">A 'ladder' pattern</td> +</tr> +<tr class="field"><th class="field-name">ladderr:</th><td class="field-body">ladder rotated 90 degrees</td> +</tr> +<tr class="field"><th class="field-name">clear:</th><td class="field-body">Just remove all dig designations</td> +</tr> +<tr class="field"><th class="field-name">cross:</th><td class="field-body">A cross, exactly in the middle of the map.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Filters:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">all:</th><td class="field-body">designate whole z-level</td> +</tr> +<tr class="field"><th class="field-name">hidden:</th><td class="field-body">designate only hidden tiles of z-level (default)</td> +</tr> +<tr class="field"><th class="field-name">designated:</th><td class="field-body">Take current designation and apply pattern to it.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>After you have a pattern set, you can use 'expdig' to apply it again.</p> +<p>Examples:</p> +<blockquote> +<dl class="docutils"> +<dt>designate the diagonal 5 patter over all hidden tiles:</dt> +<dd><ul class="first last simple"> +<li>expdig diag5 hidden</li> +</ul> +</dd> +<dt>apply last used pattern and filter:</dt> +<dd><ul class="first last simple"> +<li>expdig</li> +</ul> +</dd> +<dt>Take current designations and replace them with the ladder pattern:</dt> +<dd><ul class="first last simple"> +<li>expdig ladder designated</li> +</ul> +</dd> +</dl> +</blockquote> +</div> +<div class="section" id="digcircle"> +<h3><a class="toc-backref" href="#id63">digcircle</a></h3> +<p>A command for easy designation of filled and hollow circles. +It has several types of options.</p> +<p>Shape:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">hollow:</th><td class="field-body">Set the circle to hollow (default)</td> +</tr> +<tr class="field"><th class="field-name">filled:</th><td class="field-body">Set the circle to filled</td> +</tr> +<tr class="field"><th class="field-name">#:</th><td class="field-body">Diameter in tiles (default = 0, does nothing)</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Action:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">set:</th><td class="field-body">Set designation (default)</td> +</tr> +<tr class="field"><th class="field-name">unset:</th><td class="field-body">Unset current designation</td> +</tr> +<tr class="field"><th class="field-name">invert:</th><td class="field-body">Invert designations already present</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Designation types:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">dig:</th><td class="field-body">Normal digging designation (default)</td> +</tr> +<tr class="field"><th class="field-name">ramp:</th><td class="field-body">Ramp digging</td> +</tr> +<tr class="field"><th class="field-name">ustair:</th><td class="field-body">Staircase up</td> +</tr> +<tr class="field"><th class="field-name">dstair:</th><td class="field-body">Staircase down</td> +</tr> +<tr class="field"><th class="field-name">xstair:</th><td class="field-body">Staircase up/down</td> +</tr> +<tr class="field"><th class="field-name">chan:</th><td class="field-body">Dig channel</td> +</tr> +</tbody> +</table> +</blockquote> +<p>After you have set the options, the command called with no options +repeats with the last selected parameters.</p> +<p>Examples:</p> +<ul class="simple"> +<li>'digcircle filled 3' = Dig a filled circle with radius = 3.</li> +<li>'digcircle' = Do it again.</li> +</ul> +</div> +<div class="section" id="digtype"> +<h3><a class="toc-backref" href="#id64">digtype</a></h3> +<p>For every tile on the map of the same vein type as the selected tile, this command designates it to have the same designation as the selected tile. If the selected tile has no designation, they will be dig designated. +If an argument is given, the designation of the selected tile is ignored, and all appropriate tiles are set to the specified designation.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">dig:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">channel:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">ramp:</th><td class="field-body"></td> +</tr> +<tr class="field"><th class="field-name">updown:</th><td class="field-body">up/down stairs</td> +</tr> +<tr class="field"><th class="field-name">up:</th><td class="field-body">up stairs</td> +</tr> +<tr class="field"><th class="field-name">down:</th><td class="field-body">down stairs</td> +</tr> +<tr class="field"><th class="field-name">clear:</th><td class="field-body">clear designation</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="filltraffic"> +<h3><a class="toc-backref" href="#id65">filltraffic</a></h3> +<p>Set traffic designations using flood-fill starting at the cursor.</p> +<p>Traffic Type Codes:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">H:</th><td class="field-body">High Traffic</td> +</tr> +<tr class="field"><th class="field-name">N:</th><td class="field-body">Normal Traffic</td> +</tr> +<tr class="field"><th class="field-name">L:</th><td class="field-body">Low Traffic</td> +</tr> +<tr class="field"><th class="field-name">R:</th><td class="field-body">Restricted Traffic</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Other Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">X:</th><td class="field-body">Fill accross z-levels.</td> +</tr> +<tr class="field"><th class="field-name">B:</th><td class="field-body">Include buildings and stockpiles.</td> +</tr> +<tr class="field"><th class="field-name">P:</th><td class="field-body">Include empty space.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Example:</p> +<blockquote> +'filltraffic H' - When used in a room with doors, it will set traffic to HIGH in just that room.</blockquote> +</div> +<div class="section" id="alltraffic"> +<h3><a class="toc-backref" href="#id66">alltraffic</a></h3> +<p>Set traffic designations for every single tile of the map (useful for resetting traffic designations).</p> +<p>Traffic Type Codes:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">H:</th><td class="field-body">High Traffic</td> +</tr> +<tr class="field"><th class="field-name">N:</th><td class="field-body">Normal Traffic</td> +</tr> +<tr class="field"><th class="field-name">L:</th><td class="field-body">Low Traffic</td> +</tr> +<tr class="field"><th class="field-name">R:</th><td class="field-body">Restricted Traffic</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Example:</p> +<blockquote> +'alltraffic N' - Set traffic to 'normal' for all tiles.</blockquote> +</div> +<div class="section" id="getplants"> +<h3><a class="toc-backref" href="#id67">getplants</a></h3> +<p>This tool allows plant gathering and tree cutting by RAW ID. Specify the types +of trees to cut down and/or shrubs to gather by their plant names, separated +by spaces.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">-t:</th><td class="field-body">Select trees only (exclude shrubs)</td> +</tr> +<tr class="field"><th class="field-name">-s:</th><td class="field-body">Select shrubs only (exclude trees)</td> +</tr> +<tr class="field"><th class="field-name">-c:</th><td class="field-body">Clear designations instead of setting them</td> +</tr> +<tr class="field"><th class="field-name">-x:</th><td class="field-body">Apply selected action to all plants except those specified (invert +selection)</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Specifying both -t and -s will have no effect. If no plant IDs are specified, +all valid plant IDs will be listed.</p> +</div> +</div> +<div class="section" id="cleanup-and-garbage-disposal"> +<h2><a class="toc-backref" href="#id68">Cleanup and garbage disposal</a></h2> +<div class="section" id="clean"> +<h3><a class="toc-backref" href="#id69">clean</a></h3> +<p>Cleans all the splatter that get scattered all over the map, items and +creatures. In an old fortress, this can significantly reduce FPS lag. It can +also spoil your !!FUN!!, so think before you use it.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">map:</th><td class="field-body">Clean the map tiles. By default, it leaves mud and snow alone.</td> +</tr> +<tr class="field"><th class="field-name">units:</th><td class="field-body">Clean the creatures. Will also clean hostiles.</td> +</tr> +<tr class="field"><th class="field-name">items:</th><td class="field-body">Clean all the items. Even a poisoned blade.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Extra options for 'map':</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">mud:</th><td class="field-body">Remove mud in addition to the normal stuff.</td> +</tr> +<tr class="field"><th class="field-name">snow:</th><td class="field-body">Also remove snow coverings.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="spotclean"> +<h3><a class="toc-backref" href="#id70">spotclean</a></h3> +<p>Works like 'clean map snow mud', but only for the tile under the cursor. Ideal +if you want to keep that bloody entrance 'clean map' would clean up.</p> +</div> +<div class="section" id="autodump"> +<h3><a class="toc-backref" href="#id71">autodump</a></h3> +<p>This utility lets you quickly move all items designated to be dumped. +Items are instantly moved to the cursor position, the dump flag is unset, +and the forbid flag is set, as if it had been dumped normally. +Be aware that any active dump item tasks still point at the item.</p> +<p>Cursor must be placed on a floor tile so the items can be dumped there.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">destroy:</th><td class="field-body">Destroy instead of dumping. Doesn't require a cursor.</td> +</tr> +<tr class="field"><th class="field-name">destroy-here:</th><td class="field-body">Destroy items only under the cursor.</td> +</tr> +<tr class="field"><th class="field-name">visible:</th><td class="field-body">Only process items that are not hidden.</td> +</tr> +<tr class="field"><th class="field-name">hidden:</th><td class="field-body">Only process hidden items.</td> +</tr> +<tr class="field"><th class="field-name">forbidden:</th><td class="field-body">Only process forbidden items (default: only unforbidden).</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="autodump-destroy-here"> +<h3><a class="toc-backref" href="#id72">autodump-destroy-here</a></h3> +<p>Destroy items marked for dumping under cursor. Identical to autodump +destroy-here, but intended for use as keybinding.</p> +</div> +<div class="section" id="autodump-destroy-item"> +<h3><a class="toc-backref" href="#id73">autodump-destroy-item</a></h3> +<p>Destroy the selected item. The item may be selected in the 'k' list, or inside +a container. If called again before the game is resumed, cancels destroy.</p> +</div> +<div class="section" id="cleanowned"> +<h3><a class="toc-backref" href="#id74">cleanowned</a></h3> +<p>Confiscates items owned by dwarfs. By default, owned food on the floor +and rotten items are confistacted and dumped.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">all:</th><td class="field-body">confiscate all owned items</td> +</tr> +<tr class="field"><th class="field-name">scattered:</th><td class="field-body">confiscated and dump all items scattered on the floor</td> +</tr> +<tr class="field"><th class="field-name">x:</th><td class="field-body">confiscate/dump items with wear level 'x' and more</td> +</tr> +<tr class="field"><th class="field-name">X:</th><td class="field-body">confiscate/dump items with wear level 'X' and more</td> +</tr> +<tr class="field"><th class="field-name">dryrun:</th><td class="field-body">a dry run. combine with other options to see what will happen +without it actually happening.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Example:</p> +<blockquote> +<dl class="docutils"> +<dt><tt class="docutils literal">cleanowned scattered X</tt></dt> +<dd>This will confiscate rotten and dropped food, garbage on the floors and any +worn items with 'X' damage and above.</dd> +</dl> +</blockquote> +</div> +</div> +<div class="section" id="bugfixes"> +<h2><a class="toc-backref" href="#id75">Bugfixes</a></h2> +<div class="section" id="drybuckets"> +<h3><a class="toc-backref" href="#id76">drybuckets</a></h3> +<p>This utility removes water from all buckets in your fortress, allowing them to be safely used for making lye.</p> +</div> +<div class="section" id="fixdiplomats"> +<h3><a class="toc-backref" href="#id77">fixdiplomats</a></h3> +<p>Up to version 0.31.12, Elves only sent Diplomats to your fortress to propose +tree cutting quotas due to a bug; once that bug was fixed, Elves stopped caring +about excess tree cutting. This command adds a Diplomat position to all Elven +civilizations, allowing them to negotiate tree cutting quotas (and allowing you +to violate them and potentially start wars) in case you haven't already modified +your raws accordingly.</p> +</div> +<div class="section" id="fixmerchants"> +<h3><a class="toc-backref" href="#id78">fixmerchants</a></h3> +<p>This command adds the Guild Representative position to all Human civilizations, +allowing them to make trade agreements (just as they did back in 0.28.181.40d +and earlier) in case you haven't already modified your raws accordingly.</p> +</div> +<div class="section" id="fixveins"> +<h3><a class="toc-backref" href="#id79">fixveins</a></h3> +<p>Removes invalid references to mineral inclusions and restores missing ones. +Use this if you broke your embark with tools like tiletypes, or if you +accidentally placed a construction on top of a valuable mineral floor.</p> +</div> +<div class="section" id="tweak"> +<h3><a class="toc-backref" href="#id80">tweak</a></h3> +<p>Contains various tweaks for minor bugs.</p> +<p>One-shot subcommands:</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">clear-missing:</th><td class="field-body">Remove the missing status from the selected unit. +This allows engraving slabs for ghostly, but not yet +found, creatures.</td> +</tr> +<tr class="field"><th class="field-name">clear-ghostly:</th><td class="field-body">Remove the ghostly status from the selected unit and mark +it as dead. This allows getting rid of bugged ghosts +which do not show up in the engraving slab menu at all, +even after using clear-missing. It works, but is +potentially very dangerous - so use with care. Probably +(almost certainly) it does not have the same effects like +a proper burial. You've been warned.</td> +</tr> +<tr class="field"><th class="field-name">fixmigrant:</th><td class="field-body">Remove the resident/merchant flag from the selected unit. +Intended to fix bugged migrants/traders who stay at the +map edge and don't enter your fort. Only works for +dwarves (or generally the player's race in modded games). +Do NOT abuse this for 'real' caravan merchants (if you +really want to kidnap them, use 'tweak makeown' instead, +otherwise they will have their clothes set to forbidden etc).</td> +</tr> +<tr class="field"><th class="field-name">makeown:</th><td class="field-body">Force selected unit to become a member of your fort. +Can be abused to grab caravan merchants and escorts, even if +they don't belong to the player's race. Foreign sentients +(humans, elves) can be put to work, but you can't assign rooms +to them and they don't show up in DwarfTherapist because the +game treats them like pets. Grabbing draft animals from +a caravan can result in weirdness (animals go insane or berserk +and are not flagged as tame), but you are allowed to mark them +for slaughter. Grabbing wagons results in some funny spam, then +they are scuttled.</td> +</tr> +</tbody> +</table> +<p>Subcommands that persist until disabled or DF quit:</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">stable-cursor:</th><td class="field-body">Saves the exact cursor position between t/q/k/d/etc menus of dwarfmode.</td> +</tr> +<tr class="field"><th class="field-name">patrol-duty:</th><td class="field-body">Makes Train orders not count as patrol duty to stop unhappy thoughts. +Does NOT fix the problem when soldiers go off-duty (i.e. civilian).</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">readable-build-plate:</th></tr> +<tr class="field"><td> </td><td class="field-body">Fixes rendering of creature weight limits in pressure plate build menu.</td> +</tr> +<tr class="field"><th class="field-name">stable-temp:</th><td class="field-body">Fixes performance bug 6012 by squashing jitter in temperature updates. +In very item-heavy forts with big stockpiles this can improve FPS by 50-100%</td> +</tr> +<tr class="field"><th class="field-name">fast-heat:</th><td class="field-body">Further improves temperature update performance by ensuring that 1 degree +of item temperature is crossed in no more than specified number of frames +when updating from the environment temperature. This reduces the time it +takes for stable-temp to stop updates again when equilibrium is disturbed.</td> +</tr> +<tr class="field"><th class="field-name">fix-dimensions:</th><td class="field-body">Fixes subtracting small amount of thread/cloth/liquid from a stack +by splitting the stack and subtracting from the remaining single item. +This is a necessary addition to the binary patch in bug 808.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">advmode-contained:</th></tr> +<tr class="field"><td> </td><td class="field-body">Works around bug 6202, i.e. custom reactions with container inputs +in advmode. The issue is that the screen tries to force you to select +the contents separately from the container. This forcefully skips child +reagents.</td> +</tr> +<tr class="field"><th class="field-name">fast-trade:</th><td class="field-body">Makes Shift-Enter in the Move Goods to Depot and Trade screens select +the current item (fully, in case of a stack), and scroll down one line.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">military-stable-assign:</th></tr> +<tr class="field"><td> </td><td class="field-body">Preserve list order and cursor position when assigning to squad, +i.e. stop the rightmost list of the Positions page of the military +screen from constantly resetting to the top.</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">military-color-assigned:</th></tr> +<tr class="field"><td> </td><td class="field-body">Color squad candidates already assigned to other squads in brown/green +to make them stand out more in the list.</td> +</tr> +</tbody> +</table> +</div> +</div> +<div class="section" id="mode-switch-and-reclaim"> +<h2><a class="toc-backref" href="#id81">Mode switch and reclaim</a></h2> +<div class="section" id="lair"> +<h3><a class="toc-backref" href="#id82">lair</a></h3> +<p>This command allows you to mark the map as 'monster lair', preventing item +scatter on abandon. When invoked as 'lair reset', it does the opposite.</p> +<p>Unlike reveal, this command doesn't save the information about tiles - you +won't be able to restore state of real monster lairs using 'lair reset'.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">lair:</th><td class="field-body">Mark the map as monster lair</td> +</tr> +<tr class="field"><th class="field-name">lair reset:</th><td class="field-body">Mark the map as ordinary (not lair)</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="mode"> +<h3><a class="toc-backref" href="#id83">mode</a></h3> +<p>This command lets you see and change the game mode directly. +Not all combinations are good for every situation and most of them will +produce undesirable results. There are a few good ones though.</p> +<div class="admonition-example admonition"> +<p class="first admonition-title">Example</p> +<p class="last">You are in fort game mode, managing your fortress and paused. +You switch to the arena game mode, <em>assume control of a creature</em> and then +switch to adventure game mode(1). +You just lost a fortress and gained an adventurer. +You could also do this. +You are in fort game mode, managing your fortress and paused at the esc menu. +You switch to the adventure game mode, then use Dfusion to <em>assume control of a creature</em> and then +save or retire. +You just created a returnable mountain home and gained an adventurer.</p> +</div> +<p>I take no responsibility of anything that happens as a result of using this tool</p> +</div> +</div> +<div class="section" id="visualizer-and-data-export"> +<h2><a class="toc-backref" href="#id84">Visualizer and data export</a></h2> +<div class="section" id="ssense-stonesense"> +<h3><a class="toc-backref" href="#id85">ssense / stonesense</a></h3> +<p>An isometric visualizer that runs in a second window. This requires working +graphics acceleration and at least a dual core CPU (otherwise it will slow +down DF).</p> +<p>All the data resides in the 'stonesense' directory. For detailed instructions, +see stonesense/README.txt</p> +<p>Compatible with Windows > XP SP3 and most modern Linux distributions.</p> +<p>Older versions, support and extra graphics can be found in the bay12 forum +thread: <a class="reference external" href="http://www.bay12forums.com/smf/index.php?topic=43260.0">http://www.bay12forums.com/smf/index.php?topic=43260.0</a></p> +<p>Some additional resources: +<a class="reference external" href="http://df.magmawiki.com/index.php/Utility:Stonesense/Content_repository">http://df.magmawiki.com/index.php/Utility:Stonesense/Content_repository</a></p> +</div> +<div class="section" id="mapexport"> +<h3><a class="toc-backref" href="#id86">mapexport</a></h3> +<p>Export the current loaded map as a file. This will be eventually usable +with visualizers.</p> +</div> +<div class="section" id="dwarfexport"> +<h3><a class="toc-backref" href="#id87">dwarfexport</a></h3> +<p>Export dwarves to RuneSmith-compatible XML.</p> +</div> +</div> +<div class="section" id="job-management"> +<h2><a class="toc-backref" href="#id88">Job management</a></h2> +<div class="section" id="job"> +<h3><a class="toc-backref" href="#id89">job</a></h3> +<p>Command for general job query and manipulation.</p> +<dl class="docutils"> +<dt>Options:</dt> +<dd><dl class="first last docutils"> +<dt><em>no extra options</em></dt> +<dd>Print details of the current job. The job can be selected +in a workshop, or the unit/jobs screen.</dd> +<dt><strong>list</strong></dt> +<dd>Print details of all jobs in the selected workshop.</dd> +<dt><strong>item-material <item-idx> <material[:subtoken]></strong></dt> +<dd>Replace the exact material id in the job item.</dd> +<dt><strong>item-type <item-idx> <type[:subtype]></strong></dt> +<dd>Replace the exact item type id in the job item.</dd> +</dl> +</dd> +</dl> +</div> +<div class="section" id="job-material"> +<h3><a class="toc-backref" href="#id90">job-material</a></h3> +<p>Alter the material of the selected job.</p> +<p>Invoked as:</p> +<pre class="literal-block"> +job-material <inorganic-token> +</pre> +<p>Intended to be used as a keybinding:</p> +<blockquote> +<ul class="simple"> +<li>In 'q' mode, when a job is highlighted within a workshop or furnace, +changes the material of the job. Only inorganic materials can be used +in this mode.</li> +<li>In 'b' mode, during selection of building components positions the cursor +over the first available choice with the matching material.</li> +</ul> +</blockquote> +</div> +<div class="section" id="job-duplicate"> +<h3><a class="toc-backref" href="#id91">job-duplicate</a></h3> +<dl class="docutils"> +<dt>Duplicate the selected job in a workshop:</dt> +<dd><ul class="first last simple"> +<li>In 'q' mode, when a job is highlighted within a workshop or furnace building, +instantly duplicates the job.</li> +</ul> +</dd> +</dl> +</div> +<div class="section" id="workflow"> +<h3><a class="toc-backref" href="#id92">workflow</a></h3> +<p>Manage control of repeat jobs.</p> +<p>Usage:</p> +<blockquote> +<dl class="docutils"> +<dt><tt class="docutils literal">workflow enable <span class="pre">[option...],</span> workflow disable <span class="pre">[option...]</span></tt></dt> +<dd><p class="first">If no options are specified, enables or disables the plugin. +Otherwise, enables or disables any of the following options:</p> +<ul class="last simple"> +<li>drybuckets: Automatically empty abandoned water buckets.</li> +<li>auto-melt: Resume melt jobs when there are objects to melt.</li> +</ul> +</dd> +<dt><tt class="docutils literal">workflow jobs</tt></dt> +<dd>List workflow-controlled jobs (if in a workshop, filtered by it).</dd> +<dt><tt class="docutils literal">workflow list</tt></dt> +<dd>List active constraints, and their job counts.</dd> +<dt><tt class="docutils literal">workflow count <span class="pre"><constraint-spec></span> <span class="pre"><cnt-limit></span> <span class="pre">[cnt-gap],</span> workflow amount <span class="pre"><constraint-spec></span> <span class="pre"><cnt-limit></span> <span class="pre">[cnt-gap]</span></tt></dt> +<dd>Set a constraint. The first form counts each stack as only 1 item.</dd> +<dt><tt class="docutils literal">workflow unlimit <span class="pre"><constraint-spec></span></tt></dt> +<dd>Delete a constraint.</dd> +</dl> +</blockquote> +<div class="section" id="function"> +<h4><a class="toc-backref" href="#id93">Function</a></h4> +<p>When the plugin is enabled, it protects all repeat jobs from removal. +If they do disappear due to any cause, they are immediately re-added to their +workshop and suspended.</p> +<p>In addition, when any constraints on item amounts are set, repeat jobs that +produce that kind of item are automatically suspended and resumed as the item +amount goes above or below the limit. The gap specifies how much below the limit +the amount has to drop before jobs are resumed; this is intended to reduce +the frequency of jobs being toggled.</p> +</div> +<div class="section" id="constraint-examples"> +<h4><a class="toc-backref" href="#id94">Constraint examples</a></h4> +<p>Keep metal bolts within 900-1000, and wood/bone within 150-200.</p> +<pre class="literal-block"> +workflow amount AMMO:ITEM_AMMO_BOLTS/METAL 1000 100 +workflow amount AMMO:ITEM_AMMO_BOLTS/WOOD,BONE 200 50 +</pre> +<p>Keep the number of prepared food & drink stacks between 90 and 120</p> +<pre class="literal-block"> +workflow count FOOD 120 30 +workflow count DRINK 120 30 +</pre> +<p>Make sure there are always 25-30 empty bins/barrels/bags.</p> +<pre class="literal-block"> +workflow count BIN 30 +workflow count BARREL 30 +workflow count BOX/CLOTH,SILK,YARN 30 +</pre> +<p>Make sure there are always 15-20 coal and 25-30 copper bars.</p> +<pre class="literal-block"> +workflow count BAR//COAL 20 +workflow count BAR//COPPER 30 +</pre> +<p>Collect 15-20 sand bags and clay boulders.</p> +<pre class="literal-block"> +workflow count POWDER_MISC/SAND 20 +workflow count BOULDER/CLAY 20 +</pre> +<p>Make sure there are always 80-100 units of dimple dye.</p> +<pre class="literal-block"> + workflow amount POWDER_MISC//MUSHROOM_CUP_DIMPLE:MILL 100 20 + +In order for this to work, you have to set the material of the PLANT input +on the Mill Plants job to MUSHROOM_CUP_DIMPLE using the 'job item-material' +command. +</pre> +</div> +</div> +</div> +<div class="section" id="fortress-activity-management"> +<h2><a class="toc-backref" href="#id95">Fortress activity management</a></h2> +<div class="section" id="seedwatch"> +<h3><a class="toc-backref" href="#id96">seedwatch</a></h3> +<p>Tool for turning cooking of seeds and plants on/off depending on how much you +have of them.</p> +<p>See 'seedwatch help' for detailed description.</p> +</div> +<div class="section" id="zone"> +<h3><a class="toc-backref" href="#id97">zone</a></h3> +<p>Helps a bit with managing activity zones (pens, pastures and pits) and cages.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">set:</th><td class="field-body">Set zone or cage under cursor as default for future assigns.</td> +</tr> +<tr class="field"><th class="field-name">assign:</th><td class="field-body">Assign unit(s) to the pen or pit marked with the 'set' command. +If no filters are set a unit must be selected in the in-game ui. +Can also be followed by a valid zone id which will be set +instead.</td> +</tr> +<tr class="field"><th class="field-name">unassign:</th><td class="field-body">Unassign selected creature from it's zone.</td> +</tr> +<tr class="field"><th class="field-name">nick:</th><td class="field-body">Mass-assign nicknames, must be followed by the name you want +to set.</td> +</tr> +<tr class="field"><th class="field-name">remnick:</th><td class="field-body">Mass-remove nicknames.</td> +</tr> +<tr class="field"><th class="field-name">tocages:</th><td class="field-body">Assign unit(s) to cages inside a pasture.</td> +</tr> +<tr class="field"><th class="field-name">uinfo:</th><td class="field-body">Print info about unit(s). If no filters are set a unit must +be selected in the in-game ui.</td> +</tr> +<tr class="field"><th class="field-name">zinfo:</th><td class="field-body">Print info about zone(s). If no filters are set zones under +the cursor are listed.</td> +</tr> +<tr class="field"><th class="field-name">verbose:</th><td class="field-body">Print some more info.</td> +</tr> +<tr class="field"><th class="field-name">filters:</th><td class="field-body">Print list of valid filter options.</td> +</tr> +<tr class="field"><th class="field-name">examples:</th><td class="field-body">Print some usage examples.</td> +</tr> +<tr class="field"><th class="field-name">not:</th><td class="field-body">Negates the next filter keyword.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Filters:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">all:</th><td class="field-body">Process all units (to be used with additional filters).</td> +</tr> +<tr class="field"><th class="field-name">count:</th><td class="field-body">Must be followed by a number. Process only n units (to be used +with additional filters).</td> +</tr> +<tr class="field"><th class="field-name">unassigned:</th><td class="field-body">Not assigned to zone, chain or built cage.</td> +</tr> +<tr class="field"><th class="field-name">minage:</th><td class="field-body">Minimum age. Must be followed by number.</td> +</tr> +<tr class="field"><th class="field-name">maxage:</th><td class="field-body">Maximum age. Must be followed by number.</td> +</tr> +<tr class="field"><th class="field-name">race:</th><td class="field-body">Must be followed by a race RAW ID (e.g. BIRD_TURKEY, ALPACA, +etc). Negatable.</td> +</tr> +<tr class="field"><th class="field-name">caged:</th><td class="field-body">In a built cage. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">own:</th><td class="field-body">From own civilization. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">merchant:</th><td class="field-body">Is a merchant / belongs to a merchant. Should only be used for +pitting, not for stealing animals (slaughter should work).</td> +</tr> +<tr class="field"><th class="field-name">war:</th><td class="field-body">Trained war creature. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">hunting:</th><td class="field-body">Trained hunting creature. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">tamed:</th><td class="field-body">Creature is tame. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">trained:</th><td class="field-body">Creature is trained. Finds war/hunting creatures as well as +creatures who have a training level greater than 'domesticated'. +If you want to specifically search for war/hunting creatures use +'war' or 'hunting' Negatable.</td> +</tr> +<tr class="field"><th class="field-name">trainablewar:</th><td class="field-body">Creature can be trained for war (and is not already trained for +war/hunt). Negatable.</td> +</tr> +<tr class="field"><th class="field-name">trainablehunt:</th><td class="field-body">Creature can be trained for hunting (and is not already trained +for war/hunt). Negatable.</td> +</tr> +<tr class="field"><th class="field-name">male:</th><td class="field-body">Creature is male. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">female:</th><td class="field-body">Creature is female. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">egglayer:</th><td class="field-body">Race lays eggs. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">grazer:</th><td class="field-body">Race is a grazer. Negatable.</td> +</tr> +<tr class="field"><th class="field-name">milkable:</th><td class="field-body">Race is milkable. Negatable.</td> +</tr> +</tbody> +</table> +</blockquote> +<div class="section" id="usage-with-single-units"> +<h4><a class="toc-backref" href="#id98">Usage with single units</a></h4> +<p>One convenient way to use the zone tool is to bind the command 'zone assign' to +a hotkey, maybe also the command 'zone set'. Place the in-game cursor over +a pen/pasture or pit, use 'zone set' to mark it. Then you can select units +on the map (in 'v' or 'k' mode), in the unit list or from inside cages +and use 'zone assign' to assign them to their new home. Allows pitting your +own dwarves, by the way.</p> +</div> +<div class="section" id="usage-with-filters"> +<h4><a class="toc-backref" href="#id99">Usage with filters</a></h4> +<p>All filters can be used together with the 'assign' command.</p> +<p>Restrictions: It's not possible to assign units who are inside built cages +or chained because in most cases that won't be desirable anyways. +It's not possible to cage owned pets because in that case the owner +uncages them after a while which results in infinite hauling back and forth.</p> +<p>Usually you should always use the filter 'own' (which implies tame) unless you +want to use the zone tool for pitting hostiles. 'own' ignores own dwarves unless +you specify 'race DWARF' (so it's safe to use 'assign all own' to one big +pasture if you want to have all your animals at the same place). 'egglayer' and +'milkable' should be used together with 'female' unless you have a mod with +egg-laying male elves who give milk or whatever. Merchants and their animals are +ignored unless you specify 'merchant' (pitting them should be no problem, +but stealing and pasturing their animals is not a good idea since currently they +are not properly added to your own stocks; slaughtering them should work).</p> +<p>Most filters can be negated (e.g. 'not grazer' -> race is not a grazer).</p> +</div> +<div class="section" id="mass-renaming"> +<h4><a class="toc-backref" href="#id100">Mass-renaming</a></h4> +<p>Using the 'nick' command you can set the same nickname for multiple units. +If used without 'assign', 'all' or 'count' it will rename all units in the +current default target zone. Combined with 'assign', 'all' or 'count' (and +further optional filters) it will rename units matching the filter conditions.</p> +</div> +<div class="section" id="cage-zones"> +<h4><a class="toc-backref" href="#id101">Cage zones</a></h4> +<p>Using the 'tocages' command you can assign units to a set of cages, for example +a room next to your butcher shop(s). They will be spread evenly among available +cages to optimize hauling to and butchering from them. For this to work you need +to build cages and then place one pen/pasture activity zone above them, covering +all cages you want to use. Then use 'zone set' (like with 'assign') and use +'zone tocages filter1 filter2 ...'. 'tocages' overwrites 'assign' because it +would make no sense, but can be used together with 'nick' or 'remnick' and all +the usual filters.</p> +</div> +<div class="section" id="examples"> +<h4><a class="toc-backref" href="#id102">Examples</a></h4> +<dl class="docutils"> +<dt><tt class="docutils literal">zone assign all own ALPACA minage 3 maxage 10</tt></dt> +<dd>Assign all own alpacas who are between 3 and 10 years old to the selected +pasture.</dd> +<dt><tt class="docutils literal">zone assign all own caged grazer nick ineedgrass</tt></dt> +<dd>Assign all own grazers who are sitting in cages on stockpiles (e.g. after +buying them from merchants) to the selected pasture and give them +the nickname 'ineedgrass'.</dd> +<dt><tt class="docutils literal">zone assign all own not grazer not race CAT</tt></dt> +<dd>Assign all own animals who are not grazers, excluding cats.</dd> +<dt><tt class="docutils literal">zone assign count 5 own female milkable</tt></dt> +<dd>Assign up to 5 own female milkable creatures to the selected pasture.</dd> +<dt><tt class="docutils literal">zone assign all own race DWARF maxage 2</tt></dt> +<dd>Throw all useless kids into a pit :)</dd> +<dt><tt class="docutils literal">zone nick donttouchme</tt></dt> +<dd>Nicknames all units in the current default zone or cage to 'donttouchme'. +Mostly intended to be used for special pastures or cages which are not marked +as rooms you want to protect from autobutcher.</dd> +<dt><tt class="docutils literal">zone tocages count 50 own tame male not grazer</tt></dt> +<dd>Stuff up to 50 owned tame male animals who are not grazers into cages built +on the current default zone.</dd> +</dl> +</div> +</div> +<div class="section" id="autonestbox"> +<h3><a class="toc-backref" href="#id103">autonestbox</a></h3> +<p>Assigns unpastured female egg-layers to nestbox zones. Requires that you create +pen/pasture zones above nestboxes. If the pen is bigger than 1x1 the nestbox +must be in the top left corner. Only 1 unit will be assigned per pen, regardless +of the size. The age of the units is currently not checked, most birds grow up +quite fast. Egglayers who are also grazers will be ignored, since confining them +to a 1x1 pasture is not a good idea. Only tame and domesticated own units are +processed since pasturing half-trained wild egglayers could destroy your neat +nestbox zones when they revert to wild. When called without options autonestbox +will instantly run once.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">start:</th><td class="field-body">Start running every X frames (df simulation ticks). +Default: X=6000, which would be every 60 seconds at 100fps.</td> +</tr> +<tr class="field"><th class="field-name">stop:</th><td class="field-body">Stop running automatically.</td> +</tr> +<tr class="field"><th class="field-name">sleep:</th><td class="field-body">Must be followed by number X. Changes the timer to sleep X +frames between runs.</td> +</tr> +</tbody> +</table> +</blockquote> +</div> +<div class="section" id="autobutcher"> +<h3><a class="toc-backref" href="#id104">autobutcher</a></h3> +<p>Assigns lifestock for slaughter once it reaches a specific count. Requires that +you add the target race(s) to a watch list. Only tame units will be processed.</p> +<p>Named units will be completely ignored (to protect specific animals from +autobutcher you can give them nicknames with the tool 'rename unit' for single +units or with 'zone nick' to mass-rename units in pastures and cages).</p> +<p>Creatures trained for war or hunting will be ignored as well.</p> +<p>Creatures assigned to cages will be ignored if the cage is defined as a room +(to avoid butchering unnamed zoo animals).</p> +<p>Once you have too much adults, the oldest will be butchered first. +Once you have too much kids, the youngest will be butchered first. +If you don't set any target count the following default will be used: +1 male kid, 5 female kids, 1 male adult, 5 female adults.</p> +<p>Options:</p> +<blockquote> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">start:</th><td class="field-body">Start running every X frames (df simulation ticks). +Default: X=6000, which would be every 60 seconds at 100fps.</td> +</tr> +<tr class="field"><th class="field-name">stop:</th><td class="field-body">Stop running automatically.</td> +</tr> +<tr class="field"><th class="field-name">sleep:</th><td class="field-body">Must be followed by number X. Changes the timer to sleep +X frames between runs.</td> +</tr> +<tr class="field"><th class="field-name">watch R:</th><td class="field-body">Start watching a race. R can be a valid race RAW id (ALPACA, +BIRD_TURKEY, etc) or a list of ids seperated by spaces or +the keyword 'all' which affects all races on your current +watchlist.</td> +</tr> +<tr class="field"><th class="field-name">unwatch R:</th><td class="field-body">Stop watching race(s). The current target settings will be +remembered. R can be a list of ids or the keyword 'all'.</td> +</tr> +<tr class="field"><th class="field-name">forget R:</th><td class="field-body">Stop watching race(s) and forget it's/their target settings. +R can be a list of ids or the keyword 'all'.</td> +</tr> +<tr class="field"><th class="field-name">autowatch:</th><td class="field-body">Automatically adds all new races (animals you buy from merchants, +tame yourself or get from migrants) to the watch list using +default target count.</td> +</tr> +<tr class="field"><th class="field-name">noautowatch:</th><td class="field-body">Stop auto-adding new races to the watchlist.</td> +</tr> +<tr class="field"><th class="field-name">list:</th><td class="field-body">Print the current status and watchlist.</td> +</tr> +<tr class="field"><th class="field-name">list_export:</th><td class="field-body">Print status and watchlist in a format which can be used +to import them to another savegame (see notes).</td> +</tr> +<tr class="field"><th class="field-name" colspan="2">target fk mk fa ma R:</th></tr> +<tr class="field"><td> </td><td class="field-body">Set target count for specified race(s). +fk = number of female kids, +mk = number of male kids, +fa = number of female adults, +ma = number of female adults. +R can be a list of ids or the keyword 'all' or 'new'. +R = 'all': change target count for all races on watchlist +and set the new default for the future. R = 'new': don't touch +current settings on the watchlist, only set the new default +for future entries.</td> +</tr> +<tr class="field"><th class="field-name">example:</th><td class="field-body">Print some usage examples.</td> +</tr> +</tbody> +</table> +</blockquote> +<p>Examples:</p> +<p>You want to keep max 7 kids (4 female, 3 male) and max 3 adults (2 female, +1 male) of the race alpaca. Once the kids grow up the oldest adults will get +slaughtered. Excess kids will get slaughtered starting with the youngest +to allow that the older ones grow into adults. Any unnamed cats will +be slaughtered as soon as possible.</p> +<pre class="literal-block"> +autobutcher target 4 3 2 1 ALPACA BIRD_TURKEY +autobutcher target 0 0 0 0 CAT +autobutcher watch ALPACA BIRD_TURKEY CAT +autobutcher start +</pre> +<p>Automatically put all new races onto the watchlist and mark unnamed tame units +for slaughter as soon as they arrive in your fort. Settings already made +for specific races will be left untouched.</p> +<pre class="literal-block"> +autobutcher target 0 0 0 0 new +autobutcher autowatch +autobutcher start +</pre> +<p>Stop watching the races alpaca and cat, but remember the target count +settings so that you can use 'unwatch' without the need to enter the +values again. Note: 'autobutcher unwatch all' works, but only makes sense +if you want to keep the plugin running with the 'autowatch' feature or manually +add some new races with 'watch'. If you simply want to stop it completely use +'autobutcher stop' instead.</p> +<pre class="literal-block"> +autobutcher unwatch ALPACA CAT +</pre> +<p><strong>Note:</strong></p> +<p>Settings and watchlist are stored in the savegame, so that you can have +different settings for each world. If you want to copy your watchlist to +another savegame you can use the command list_export:</p> +<pre class="literal-block"> +Load savegame where you made the settings. +Start a CMD shell and navigate to the df directory. Type the following into the shell: +dfhack-run autobutcher list_export > autobutcher.bat +Load the savegame where you want to copy the settings to, run the batch file (from the shell): +autobutcher.bat +</pre> +</div> +<div class="section" id="autolabor"> +<h3><a class="toc-backref" href="#id105">autolabor</a></h3> +<p>Automatically manage dwarf labors.</p> +<p>When enabled, autolabor periodically checks your dwarves and enables or +disables labors. It tries to keep as many dwarves as possible busy but +also tries to have dwarves specialize in specific skills.</p> +<div class="note"> +<p class="first admonition-title">Note</p> +<p class="last">Warning: autolabor will override any manual changes you make to labors +while it is enabled.</p> +</div> +<p>For detailed usage information, see 'help autolabor'.</p> +</div> +</div> +<div class="section" id="other"> +<h2><a class="toc-backref" href="#id106">Other</a></h2> +<div class="section" id="catsplosion"> +<h3><a class="toc-backref" href="#id107">catsplosion</a></h3> +<p>Makes cats just <em>multiply</em>. It is not a good idea to run this more than once or +twice.</p> +</div> +<div class="section" id="dfusion"> +<h3><a class="toc-backref" href="#id108">dfusion</a></h3> +<p>This is the DFusion lua plugin system by warmist/darius, running as a DFHack plugin.</p> +<p>See the bay12 thread for details: <a class="reference external" href="http://www.bay12forums.com/smf/index.php?topic=69682.15">http://www.bay12forums.com/smf/index.php?topic=69682.15</a></p> +<p>Confirmed working DFusion plugins:</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name">simple_embark:</th><td class="field-body">allows changing the number of dwarves available on embark.</td> +</tr> +</tbody> +</table> +<div class="note"> +<p class="first admonition-title">Note</p> +<ul class="last simple"> +<li>Some of the DFusion plugins aren't completely ported yet. This can lead to crashes.</li> +<li>This is currently working only on Windows.</li> +<li>The game will be suspended while you're using dfusion. Don't panic when it doen't respond.</li> +</ul> +</div> +</div> +<div class="section" id="misery"> +<h3><a class="toc-backref" href="#id109">misery</a></h3> +<p>When enabled, every new negative dwarven thought will be multiplied by a factor (2 by default).</p> +<p>Usage:</p> +<table class="docutils field-list" frame="void" rules="none"> +<col class="field-name" /> +<col class="field-body" /> +<tbody valign="top"> +<tr class="field"><th class="field-name" colspan="2">misery enable n:</th></tr> +<tr class="field"><td> </td><td class="field-body">enable misery with optional magnitude n. If specified, n must be positive.</td> +</tr> +<tr class="field"><th class="field-name">misery n:</th><td class="field-body">same as "misery enable n"</td> +</tr> +<tr class="field"><th class="field-name">misery enable:</th><td class="field-body">same as "misery enable 2"</td> +</tr> +<tr class="field"><th class="field-name">misery disable:</th><td class="field-body">stop adding new negative thoughts. This will not remove existing duplicated thoughts. Equivalent to "misery 1"</td> +</tr> +<tr class="field"><th class="field-name">misery clear:</th><td class="field-body">remove fake thoughts added in this session of DF. Saving makes them permanent! Does not change factor.</td> +</tr> +</tbody> +</table> +</div> +</div> +</div> +<div class="section" id="scripts"> +<h1><a class="toc-backref" href="#id110">Scripts</a></h1> +<p>Lua or ruby scripts placed in the hack/scripts/ directory are considered for +execution as if they were native DFHack commands. They are listed at the end +of the 'ls' command output.</p> +<p>Note: scripts in subdirectories of hack/scripts/ can still be called, but will +only be listed by ls if called as 'ls -a'. This is intended as a way to hide +scripts that are obscure, developer-oriented, or should be used as keybindings.</p> +<p>Some notable scripts:</p> +<div class="section" id="fix"> +<h2><a class="toc-backref" href="#id111">fix/*</a></h2> +<p>Scripts in this subdirectory fix various bugs and issues, some of them obscure.</p> +<ul> +<li><p class="first">fix/dead-units</p> +<p>Removes uninteresting dead units from the unit list. Doesn't seem to give any +noticeable performance gain, but migrants normally stop if the unit list grows +to around 3000 units, and this script reduces it back.</p> +</li> +<li><p class="first">fix/population-cap</p> +<p>Run this after every migrant wave to ensure your population cap is not exceeded. +The issue with the cap is that it is compared to the population number reported +by the last caravan, so once it drops below the cap, migrants continue to come +until that number is updated again.</p> +</li> +<li><p class="first">fix/stable-temp</p> +<p>Instantly sets the temperature of all free-lying items to be in equilibrium with +the environment and stops temperature updates. In order to maintain this efficient +state however, use <tt class="docutils literal">tweak <span class="pre">stable-temp</span></tt> and <tt class="docutils literal">tweak <span class="pre">fast-heat</span></tt>.</p> +</li> +<li><p class="first">fix/item-occupancy</p> +<p>Diagnoses and fixes issues with nonexistant 'items occupying site', usually +caused by autodump bugs or other hacking mishaps.</p> +</li> +</ul> +</div> +<div class="section" id="gui"> +<h2><a class="toc-backref" href="#id112">gui/*</a></h2> +<p>Scripts that implement dialogs inserted into the main game window are put in this +directory.</p> +</div> +<div class="section" id="quicksave"> +<h2><a class="toc-backref" href="#id113">quicksave</a></h2> +<p>If called in dwarf mode, makes DF immediately auto-save the game by setting a flag +normally used in seasonal auto-save.</p> +</div> +<div class="section" id="setfps"> +<h2><a class="toc-backref" href="#id114">setfps</a></h2> +<p>Run <tt class="docutils literal">setfps <number></tt> to set the FPS cap at runtime, in case you want to watch +combat in slow motion or something :)</p> +</div> +<div class="section" id="siren"> +<h2><a class="toc-backref" href="#id115">siren</a></h2> +<p>Wakes up sleeping units, cancels breaks and stops parties either everywhere, +or in the burrows given as arguments. In return, adds bad thoughts about +noise, tiredness and lack of protection. Also, the units with interrupted +breaks will go on break again a lot sooner. The script is intended for +emergencies, e.g. when a siege appears, and all your military is partying.</p> +</div> +<div class="section" id="growcrops"> +<h2><a class="toc-backref" href="#id116">growcrops</a></h2> +<p>Instantly grow seeds inside farming plots.</p> +<p>With no argument, this command list the various seed types currently in +use in your farming plots. +With a seed type, the script will grow 100 of these seeds, ready to be +harvested. You can change the number with a 2nd argument.</p> +<p>For exemple, to grow 40 plump helmet spawn:</p> +<pre class="literal-block"> +growcrops plump 40 +</pre> +</div> +<div class="section" id="removebadthoughts"> +<h2><a class="toc-backref" href="#id117">removebadthoughts</a></h2> +<p>This script remove negative thoughts from your dwarves. Very useful against +tantrum spirals.</p> +<p>With a selected unit in 'v' mode, will clear this unit's mind, otherwise +clear all your fort's units minds.</p> +<p>Individual dwarf happiness may not increase right after this command is run, +but in the short term your dwarves will get much more joyful. +The thoughts are set to be very old, and the game will remove them soon when +you unpause.</p> +<p>With the optional <tt class="docutils literal"><span class="pre">-v</span></tt> parameter, the script will dump the negative thoughts +it removed.</p> +</div> +<div class="section" id="slayrace"> +<h2><a class="toc-backref" href="#id118">slayrace</a></h2> +<p>Kills any unit of a given race.</p> +<p>With no argument, lists the available races.</p> +<p>With the special argument 'him', targets only the selected creature.</p> +<p>Any non-dead non-caged unit of the specified race gets its <tt class="docutils literal">blood_count</tt> +set to 0, which means immediate death at the next game tick. For creatures +such as vampires, also set animal.vanish_countdown to 2.</p> +<p>An alternate mode is selected by adding a 2nd argument to the command, +<tt class="docutils literal">magma</tt>. In this case, a column of 7/7 magma is generated on top of the +targets until they die (Warning: do not call on magma-safe creatures. Also, +using this mode for birds is not recommanded.)</p> +<p>Will target any unit on a revealed tile of the map, including ambushers.</p> +<p>Ex:</p> +<pre class="literal-block"> +slayrace gob +</pre> +<p>To kill a single creature, select the unit with the 'v' cursor and:</p> +<pre class="literal-block"> +slayrace him +</pre> +<p>To purify all elves on the map with fire (may have side-effects):</p> +<pre class="literal-block"> +slayrace elve magma +</pre> +</div> +<div class="section" id="magmasource"> +<h2><a class="toc-backref" href="#id119">magmasource</a></h2> +<p>Create an infinite magma source on a tile.</p> +<p>This script registers a map tile as a magma source, and every 12 game ticks +that tile receives 1 new unit of flowing magma.</p> +<p>Place the game cursor where you want to create the source (must be a +flow-passable tile, and not too high in the sky) and call:</p> +<pre class="literal-block"> +magmasource here +</pre> +<p>To add more than 1 unit everytime, call the command again.</p> +<p>To delete one source, place the cursor over its tile and use <tt class="docutils literal"><span class="pre">delete-here</span></tt>. +To remove all placed sources, call <tt class="docutils literal">magmasource stop</tt>.</p> +<p>With no argument, this command shows an help message and list existing sources.</p> +</div> +<div class="section" id="digfort"> +<h2><a class="toc-backref" href="#id120">digfort</a></h2> +<p>A script to designate an area for digging according to a plan in csv format.</p> +<p>This script, inspired from quickfort, can designate an area for digging. +Your plan should be stored in a .csv file like this:</p> +<pre class="literal-block"> +# this is a comment +d;d;u;d;d;skip this tile;d +d;d;d;i +</pre> +<p>Available tile shapes are named after the 'dig' menu shortcuts: +<tt class="docutils literal">d</tt> for dig, <tt class="docutils literal">u</tt> for upstairs, <tt class="docutils literal">d</tt> downstairs, <tt class="docutils literal">i</tt> updown, +<tt class="docutils literal">h</tt> channel, <tt class="docutils literal">r</tt> upward ramp, <tt class="docutils literal">x</tt> remove designation. +Unrecognized characters are ignored (eg the 'skip this tile' in the sample).</p> +<p>Empty lines and data after a <tt class="docutils literal">#</tt> are ignored as comments. +To skip a row in your design, use a single <tt class="docutils literal">;</tt>.</p> +<p>The script takes the plan filename, starting from the root df folder.</p> +</div> +<div class="section" id="superdwarf"> +<h2><a class="toc-backref" href="#id121">superdwarf</a></h2> +<p>Similar to fastdwarf, per-creature.</p> +<p>To make any creature superfast, target it ingame using 'v' and:</p> +<pre class="literal-block"> +superdwarf add +</pre> +<p>Other options available: <tt class="docutils literal">del</tt>, <tt class="docutils literal">clear</tt>, <tt class="docutils literal">list</tt>.</p> +<p>This plugin also shortens the 'sleeping' and 'on break' periods of targets.</p> +</div> +<div class="section" id="drainaquifer"> +<h2><a class="toc-backref" href="#id122">drainaquifer</a></h2> +<p>Remove all 'aquifer' tag from the map blocks. Irreversible.</p> +</div> +<div class="section" id="deathcause"> +<h2><a class="toc-backref" href="#id123">deathcause</a></h2> +<p>Focus a body part ingame, and this script will display the cause of death of +the creature.</p> +</div> +</div> +<div class="section" id="in-game-interface-tools"> +<h1><a class="toc-backref" href="#id124">In-game interface tools</a></h1> +<p>These tools work by displaying dialogs or overlays in the game window, and +are mostly implemented by lua scripts.</p> +<div class="note"> +<p class="first admonition-title">Note</p> +<p>In order to avoid user confusion, as a matter of policy all these tools +display the word "DFHack" on the screen somewhere while active.</p> +<p class="last">As an exception, the tweak plugin described above does not follow this +guideline because it arguably just fixes small usability bugs in the game UI.</p> +</div> +<div class="section" id="dwarf-manipulator"> +<h2><a class="toc-backref" href="#id125">Dwarf Manipulator</a></h2> +<p>Implemented by the manipulator plugin. To activate, open the unit screen and +press 'l'.</p> +<p>This tool implements a Dwarf Therapist-like interface within the game UI. The +far left column displays the unit's Happiness (color-coded based on its +value), and the right half of the screen displays each dwarf's labor settings +and skill levels (0-9 for Dabbling thru Professional, A-E for Great thru Grand +Master, and U-Z for Legendary thru Legendary+5). Cells with red backgrounds +denote skills not controlled by labors.</p> +<p>Use the arrow keys or number pad to move the cursor around, holding Shift to +move 10 tiles at a time.</p> +<p>Press the Z-Up (<) and Z-Down (>) keys to move quickly between labor/skill +categories. The numpad Z-Up and Z-Down keys seek to the first or last unit +in the list. Backspace seeks to the top left corner.</p> +<p>Press Enter to toggle the selected labor for the selected unit, or Shift+Enter +to toggle all labors within the selected category.</p> +<p>Press the <tt class="docutils literal">+-</tt> keys to sort the unit list according to the currently selected +skill/labor, and press the <tt class="docutils literal">*/</tt> keys to sort the unit list by Name, Profession, +Happiness, or Arrival order (using Tab to select which sort method to use here).</p> +<p>With a unit selected, you can press the "v" key to view its properties (and +possibly set a custom nickname or profession) or the "c" key to exit +Manipulator and zoom to its position within your fortress.</p> +<p>The following mouse shortcuts are also available:</p> +<ul class="simple"> +<li>Click on a column header to sort the unit list. Left-click to sort it in one +direction (descending for happiness or labors/skills, ascending for name or +profession) and right-click to sort it in the opposite direction.</li> +<li>Left-click on a labor cell to toggle that labor. Right-click to move the +cursor onto that cell instead of toggling it.</li> +<li>Left-click on a unit's name or profession to view its properties.</li> +<li>Right-click on a unit's name or profession to zoom to it.</li> +</ul> +<p>Pressing ESC normally returns to the unit screen, but Shift-ESC would exit +directly to the main dwarf mode screen.</p> +</div> +<div class="section" id="gui-liquids"> +<h2><a class="toc-backref" href="#id126">gui/liquids</a></h2> +<p>To use, bind to a key and activate in the 'k' mode.</p> +<p>While active, use the suggested keys to switch the usual liquids parameters, and Enter +to select the target area and apply changes.</p> +</div> +<div class="section" id="gui-mechanisms"> +<h2><a class="toc-backref" href="#id127">gui/mechanisms</a></h2> +<p>To use, bind to a key and activate in the 'q' mode.</p> +<p>Lists mechanisms connected to the building, and their links. Navigating the list centers +the view on the relevant linked buildings.</p> +<p>To exit, press ESC or Enter; ESC recenters on the original building, while Enter leaves +focus on the current one. Shift-Enter has an effect equivalent to pressing Enter, and then +re-entering the mechanisms ui.</p> +</div> +<div class="section" id="gui-rename"> +<h2><a class="toc-backref" href="#id128">gui/rename</a></h2> +<p>Backed by the rename plugin, this script allows entering the desired name +via a simple dialog in the game ui.</p> +<ul> +<li><p class="first"><tt class="docutils literal">gui/rename [building]</tt> in 'q' mode changes the name of a building.</p> +<p>The selected building must be one of stockpile, workshop, furnace, trap, or siege engine. +It is also possible to rename zones from the 'i' menu.</p> +</li> +<li><p class="first"><tt class="docutils literal">gui/rename [unit]</tt> with a unit selected changes the nickname.</p> +</li> +<li><p class="first"><tt class="docutils literal">gui/rename <span class="pre">unit-profession</span></tt> changes the selected unit's custom profession name.</p> +</li> +</ul> +<p>The <tt class="docutils literal">building</tt> or <tt class="docutils literal">unit</tt> options are automatically assumed when in relevant ui state.</p> +</div> +<div class="section" id="gui-room-list"> +<h2><a class="toc-backref" href="#id129">gui/room-list</a></h2> +<p>To use, bind to a key and activate in the 'q' mode, either immediately or after opening +the assign owner page.</p> +<p>The script lists other rooms owned by the same owner, or by the unit selected in the assign +list, and allows unassigning them.</p> +</div> +<div class="section" id="gui-choose-weapons"> +<h2><a class="toc-backref" href="#id130">gui/choose-weapons</a></h2> +<p>Bind to a key, and activate in the Equip->View/Customize page of the military screen.</p> +<p>Depending on the cursor location, it rewrites all 'individual choice weapon' entries +in the selected squad or position to use a specific weapon type matching the assigned +unit's top skill. If the cursor is in the rightmost list over a weapon entry, it rewrites +only that entry, and does it even if it is not 'individual choice'.</p> +<p>Rationale: individual choice seems to be unreliable when there is a weapon shortage, +and may lead to inappropriate weapons being selected.</p> +</div> +</div> +<div class="section" id="behavior-mods"> +<h1><a class="toc-backref" href="#id131">Behavior Mods</a></h1> +<p>These plugins, when activated via configuration UI or by detecting certain +structures in RAWs, modify the game engine behavior concerning the target +objects to add features not otherwise present.</p> +<div class="admonition-disclaimer admonition"> +<p class="first admonition-title">DISCLAIMER</p> +<p class="last">The plugins in this section have mostly been created for fun as an interesting +technical challenge, and do not represent any long-term plans to produce more +similar modifications of the game.</p> +</div> +<div class="section" id="siege-engine"> +<h2><a class="toc-backref" href="#id132">Siege Engine</a></h2> +<p>The siege-engine plugin enables siege engines to be linked to stockpiles, and +aimed at an arbitrary rectangular area across Z levels, instead of the original +four directions. Also, catapults can be ordered to load arbitrary objects, not +just stones.</p> +<div class="section" id="rationale"> +<h3><a class="toc-backref" href="#id133">Rationale</a></h3> +<p>Siege engines are a very interesting feature, but sadly almost useless in the current state +because they haven't been updated since 2D and can only aim in four directions. This is an +attempt to bring them more up to date until Toady has time to work on it. Actual improvements, +e.g. like making siegers bring their own, are something only Toady can do.</p> +</div> +<div class="section" id="configuration-ui"> +<h3><a class="toc-backref" href="#id134">Configuration UI</a></h3> +<p>The configuration front-end to the plugin is implemented by the gui/siege-engine +script. Bind it to a key and activate after selecting a siege engine in 'q' mode.</p> +<p>The main mode displays the current target, selected ammo item type, linked stockpiles and +the allowed operator skill range. The map tile color is changed to signify if it can be +hit by the selected engine: green for fully reachable, blue for out of range, red for blocked, +yellow for partially blocked.</p> +<p>Pressing 'r' changes into the target selection mode, which works by highlighting two points +with Enter like all designations. When a target area is set, the engine projectiles are +aimed at that area, or units within it (this doesn't actually change the original aiming +code, instead the projectile trajectory parameters are rewritten as soon as it appears).</p> +<p>After setting the target in this way for one engine, you can 'paste' the same area into others +just by pressing 'p' in the main page of this script. The area to paste is kept until you quit +DF, or select another area manually.</p> +<p>Pressing 't' switches to a mode for selecting a stockpile to take ammo from.</p> +<p>Exiting from the siege engine script via ESC reverts the view to the state prior to starting +the script. Shift-ESC retains the current viewport, and also exits from the 'q' mode to main +menu.</p> +</div> +</div> +<div class="section" id="power-meter"> +<h2><a class="toc-backref" href="#id135">Power Meter</a></h2> +<p>The power-meter plugin implements a modified pressure plate that detects power being +supplied to gear boxes built in the four adjacent N/S/W/E tiles.</p> +<p>The configuration front-end is implemented by the gui/power-meter script. Bind it to a +key and activate after selecting Pressure Plate in the build menu.</p> +<p>The script follows the general look and feel of the regular pressure plate build +configuration page, but configures parameters relevant to the modded power meter building.</p> +</div> +<div class="section" id="steam-engine"> +<h2><a class="toc-backref" href="#id136">Steam Engine</a></h2> +<p>The steam-engine plugin detects custom workshops with STEAM_ENGINE in +their token, and turns them into real steam engines.</p> +<div class="section" id="id1"> +<h3><a class="toc-backref" href="#id137">Rationale</a></h3> +<p>The vanilla game contains only water wheels and windmills as sources of +power, but windmills give relatively little power, and water wheels require +flowing water, which must either be a real river and thus immovable and +limited in supply, or actually flowing and thus laggy.</p> +<p>Steam engines are an alternative to water reactors that actually makes +sense, and hopefully doesn't lag. Also, unlike e.g. animal treadmills, +it can be done just by combining existing features of the game engine +in a new way with some glue code and a bit of custom logic.</p> +</div> +<div class="section" id="construction"> +<h3><a class="toc-backref" href="#id138">Construction</a></h3> +<p>The workshop needs water as its input, which it takes via a +passable floor tile below it, like usual magma workshops do. +The magma version also needs magma.</p> +<div class="admonition-issue admonition"> +<p class="first admonition-title">ISSUE</p> +<p class="last">Since this building is a machine, and machine collapse +code cannot be hooked, it would collapse over true open space. +As a loophole, down stair provides support to machines, while +being passable, so use them.</p> +</div> +<p>After constructing the building itself, machines can be connected +to the edge tiles that look like gear boxes. Their exact position +is extracted from the workshop raws.</p> +<div class="admonition-issue admonition"> +<p class="first admonition-title">ISSUE</p> +<p class="last">Like with collapse above, part of the code involved in +machine connection cannot be hooked. As a result, the workshop +can only immediately connect to machine components built AFTER it. +This also means that engines cannot be chained without intermediate +short axles that can be built later than both of the engines.</p> +</div> +</div> +<div class="section" id="operation"> +<h3><a class="toc-backref" href="#id139">Operation</a></h3> +<p>In order to operate the engine, queue the Stoke Boiler job (optionally +on repeat). A furnace operator will come, possibly bringing a bar of fuel, +and perform it. As a result, a "boiling water" item will appear +in the 't' view of the workshop.</p> +<div class="note"> +<p class="first admonition-title">Note</p> +<p class="last">The completion of the job will actually consume one unit +of the appropriate liquids from below the workshop. This means +that you cannot just raise 7 units of magma with a piston and +have infinite power. However, liquid consumption should be slow +enough that water can be supplied by a pond zone bucket chain.</p> +</div> +<p>Every such item gives 100 power, up to a limit of 300 for coal, +and 500 for a magma engine. The building can host twice that +amount of items to provide longer autonomous running. When the +boiler gets filled to capacity, all queued jobs are suspended; +once it drops back to 3+1 or 5+1 items, they are re-enabled.</p> +<p>While the engine is providing power, steam is being consumed. +The consumption speed includes a fixed 10% waste rate, and +the remaining 90% are applied proportionally to the actual +load in the machine. With the engine at nominal 300 power with +150 load in the system, it will consume steam for actual +300*(10% + 90%*150/300) = 165 power.</p> +<p>Masterpiece mechanism and chain will decrease the mechanical +power drawn by the engine itself from 10 to 5. Masterpiece +barrel decreases waste rate by 4%. Masterpiece piston and pipe +decrease it by further 4%, and also decrease the whole steam +use rate by 10%.</p> +</div> +<div class="section" id="explosions"> +<h3><a class="toc-backref" href="#id140">Explosions</a></h3> +<p>The engine must be constructed using barrel, pipe and piston +from fire-safe, or in the magma version magma-safe metals.</p> +<p>During operation weak parts get gradually worn out, and +eventually the engine explodes. It should also explode if +toppled during operation by a building destroyer, or a +tantruming dwarf.</p> +</div> +<div class="section" id="save-files"> +<h3><a class="toc-backref" href="#id141">Save files</a></h3> +<p>It should be safe to load and view engine-using fortresses +from a DF version without DFHack installed, except that in such +case the engines won't work. However actually making modifications +to them, or machines they connect to (including by pulling levers), +can easily result in inconsistent state once this plugin is +available again. The effects may be as weird as negative power +being generated.</p> +</div> +</div> +<div class="section" id="add-spatter"> +<h2><a class="toc-backref" href="#id142">Add Spatter</a></h2> +<p>This plugin makes reactions with names starting with <tt class="docutils literal">SPATTER_ADD_</tt> +produce contaminants on the items instead of improvements. The produced +contaminants are immune to being washed away by water or destroyed by +the <tt class="docutils literal">clean items</tt> command.</p> +<p>The plugin is intended to give some use to all those poisons that can +be bought from caravans. :)</p> +<p>To be really useful this needs patches from bug 808, <tt class="docutils literal">tweak <span class="pre">fix-dimensions</span></tt> +and <tt class="docutils literal">tweak <span class="pre">advmode-contained</span></tt>.</p> +</div> +</div> +</div> +</body> +</html> diff --git a/fixTexts.sh b/fixTexts.sh new file mode 100755 index 00000000..e8d89044 --- /dev/null +++ b/fixTexts.sh @@ -0,0 +1,6 @@ +#!/bin/bash +# this script is used for easy testing of the rst documentation files. +rst2html Readme.rst Readme.html +rst2html Compile.rst Compile.html +rst2html LUA\ Api.rst LUA\ Api.html +rst2html Contributors.rst > Contributors.html diff --git a/testTexts.sh b/testTexts.sh deleted file mode 100755 index 0189ae2a..00000000 --- a/testTexts.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/bin/bash -# this script is used for easy testing of the rst documentation files. -rst2html README.rst > README.html -rst2html COMPILE.rst > COMPILE.html -rst2html LUA_API.rst > LUA_API.html |
