From 2b1d856214e30ff832e664141070a77b9a736c4c Mon Sep 17 00:00:00 2001
From: Alexander Gavrilov
Download and unpack a copy of the latest DF
+Install Xcode from Mac App Store
+Open Xcode, go to Preferences > Downloads, and install the Command Line Tools.
+Install MacPorts.
+Install dependencies from MacPorts:
+sudo port install gcc45 +universal cmake +universal git-core +universal
+This will take some time—maybe hours, depending on your machine.
+At some point during this process, it may ask you to install a Java environment; let it do so.
+Install perl dependencies
++++
+- +
sudo cpan
+If this is the first time you've run cpan, you will need to go through the setup +process. Just stick with the defaults for everything and you'll be fine.
+- +
install XML::LibXML
+- +
install XML::LibXSLT
+
Get the dfhack source:
++git clone https://github.com/danaris/dfhack.git +cd dfhack +git submodule init +git submodule update ++
Build dfhack:
++mkdir build-osx +cd build-osx +export CC=/opt/local/bin/gcc-mp-4.5 +export CXX=/opt/local/bin/g++-mp-4.5 +cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX=/path/to/DF/directory +make +make install ++
On Windows, DFHack replaces the SDL library distributed with DF.
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:
@@ -428,7 +484,7 @@ git submodule updateIf 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).
First, you need cmake. Get the win32 installer version from the official site: http://www.cmake.org/cmake/resources/software.html
It has the usual installer wizard. Make sure you let it add its binary folder @@ -445,7 +501,7 @@ Grab it from Microsoft's site.
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.
There are several different batch files in the build folder along with a script that's used for picking the DF path.
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 generate prefix. These create the MSVC solution file(s):
@@ -467,7 +523,7 @@ So pick either Release or RelWithDebInfo build and build the INSTALL target.cmake allows you to pick a build type by changing this variable: CMAKE_BUILD_TYPE
@@ -479,7 +535,7 @@ cmake .. -DCMAKE_BUILD_TYPE:string=BUILD_TYPE 'RelWithDebInfo'. 'Debug' is not available on Windows.
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.
@@ -497,29 +553,29 @@ The main license is zlib/libpng, some bits are MIT licensed, and some are BSD liFeel free to add your own extensions and plugins. Contributing back to the dfhack repository is welcome and the right thing to do :)
DFHack uses information about the game data structures, represented via xml files in the library/xml/ submodule.
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.
Global object addresses are stored in symbols.xml, which is copied to the dfhack release package and loaded as data at runtime.
DFHack supports remote access by exchanging Google protobuf messages via a TCP socket. Both the core and plugins can define remotely accessible methods. The dfhack-run command uses this interface to invoke ordinary console commands.
Currently the supported set of requests is limited, because the developers don't know what exactly is most useful.
Protocol client implementations exist for Java and C#.
Several things should be kept in mind when contributing to DFHack.
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 you fix it ;)
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.
@@ -529,7 +585,7 @@ this is also a good place to dump new ideas and/or bugs that need fixing.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 :)
diff --git a/Compile.rst b/Compile.rst index a71642060..3340fc97e 100644 --- a/Compile.rst +++ b/Compile.rst @@ -72,24 +72,39 @@ Mac OS X 3. Open Xcode, go to Preferences > Downloads, and install the Command Line Tools. 4. Install MacPorts. 5. Install dependencies from MacPorts: - * sudo port install gcc45 +universal cmake +universal git-core +universal (This will take some time—maybe hours, depending on your machine.) - * At some point during this process, it may ask you to install a Java environment; let it do so. + + * ``sudo port install gcc45 +universal cmake +universal git-core +universal`` + + This will take some time—maybe hours, depending on your machine. + + * At some point during this process, it may ask you to install a Java environment; let it do so. + 6. Install perl dependencies - 1. sudo cpan (If this is the first time you've run cpan, you will need to go through the setup process. Just stick with the defaults for everything and you'll be fine.) - 2. install XML::LibXML - 3. install XML::LibXSLT -7. Get the dfhack source - 1. git clone https://github.com/danaris/dfhack.git - 2. cd dfhack - 3. git submodule init - 4. git submodule update -8. mkdir build-osx -9. cd build-osx -10. export CC=/opt/local/bin/gcc-mp-4.5 -11. export CXX=/opt/local/bin/g++-mp-4.5 -12. cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX=/path/to/DF/directory -13. make -14. make install + + 1. ``sudo cpan`` + + If this is the first time you've run cpan, you will need to go through the setup + process. Just stick with the defaults for everything and you'll be fine. + + 2. ``install XML::LibXML`` + 3. ``install XML::LibXSLT`` + +7. Get the dfhack source:: + + git clone https://github.com/danaris/dfhack.git + cd dfhack + git submodule init + git submodule update + +8. Build dfhack:: + + mkdir build-osx + cd build-osx + export CC=/opt/local/bin/gcc-mp-4.5 + export CXX=/opt/local/bin/g++-mp-4.5 + cmake .. -DCMAKE_BUILD_TYPE:string=Release -DCMAKE_INSTALL_PREFIX=/path/to/DF/directory + make + make install ======= Windows diff --git a/Lua API.html b/Lua API.html index 125687110..9c18b6585 100644 --- a/Lua API.html +++ b/Lua API.html @@ -1110,6 +1110,13 @@ above operations accordingly. If enabled, pauses and zooms to position. if there are any jobs with first_id <= id < job_next_id, a lua list containing them. +dfhack.job.isSuitableItem(job_item, item_type, item_subtype)
+Does basic sanity checks to verify if the suggested item type matches +the flags in the job item.
+dfhack.job.isSuitableMaterial(job_item, mat_type, mat_index)
+Likewise, if replacing material.
+dfhack.items.makeProjectile(item)
Turns the item into a projectile, and returns the new object, or nil if impossible.
dfhack.items.isCasteMaterial(item_type)
+Returns true if this item type uses a creature/caste pair as its material.
+dfhack.items.getSubtypeCount(item_type)
+Returns the number of raw-defined subtypes of the given item type, or -1 if not applicable.
+dfhack.items.getSubtypeDef(item_type, subtype)
+Returns the raw definition for the given item type and subtype, or nil if invalid.
+dfhack.maps.getBlock(x,y,z)
Returns a map block object for given x,y,z in local block coordinates.
dfhack.maps.isValidTilePos(coords), or isValidTilePos(x,y,z)``
+dfhack.maps.isValidTilePos(coords), or isValidTilePos(x,y,z)
Checks if the given df::coord or x,y,z in local tile coordinates are valid.
dfhack.maps.getTileBlock(coords), or getTileBlock(x,y,z)
@@ -1273,6 +1289,12 @@ Returns false in case of error.dfhack.maps.ensureTileBlock(coords), or ensureTileBlock(x,y,z)
Like getTileBlock, but if the block is not allocated, try creating it.
dfhack.maps.getTileType(coords), or getTileType(x,y,z)
+Returns the tile type at the given coordinates, or nil if invalid.
+dfhack.maps.getTileFlags(coords), or getTileFlags(x,y,z)
+Returns designation and occupancy references for the given coordinates, or nil, nil if invalid.
+dfhack.maps.getRegionBiome(region_coord2d), or getRegionBiome(x,y)
Returns the biome info struct for the given global map region.
xyz2pos(x,y,z)
Returns a table with x, y and z as fields.
same_xyz(a,b)
+Checks if a and b have the same x, y and z fields.
+get_path_xyz(path,i)
+Returns path.x[i], path.y[i], path.z[i].
+pos2xy(obj), xy2pos(x,y), same_xy(a,b), get_path_xy(a,b)
+Same as above, but for 2D coordinates.
+safe_index(obj,index...)
Walks a sequence of dereferences, which may be represented by numbers or strings. Returns nil if any of obj or indices is nil, or a numeric index is out of array bounds.
diff --git a/Lua API.rst b/Lua API.rst index 4d689ee2b..185672816 100644 --- a/Lua API.rst +++ b/Lua API.rst @@ -1043,6 +1043,18 @@ Items module Turns the item into a projectile, and returns the new object, or *nil* if impossible. +* ``dfhack.items.isCasteMaterial(item_type)`` + + Returns *true* if this item type uses a creature/caste pair as its material. + +* ``dfhack.items.getSubtypeCount(item_type)`` + + Returns the number of raw-defined subtypes of the given item type, or *-1* if not applicable. + +* ``dfhack.items.getSubtypeDef(item_type, subtype)`` + + Returns the raw definition for the given item type and subtype, or *nil* if invalid. + Maps module ----------- @@ -1059,7 +1071,7 @@ Maps module Returns a map block object for given x,y,z in local block coordinates. -* ``dfhack.maps.isValidTilePos(coords)``, or isValidTilePos(x,y,z)`` +* ``dfhack.maps.isValidTilePos(coords)``, or ``isValidTilePos(x,y,z)`` Checks if the given df::coord or x,y,z in local tile coordinates are valid. @@ -1071,6 +1083,14 @@ Maps module Like ``getTileBlock``, but if the block is not allocated, try creating it. +* ``dfhack.maps.getTileType(coords)``, or ``getTileType(x,y,z)`` + + Returns the tile type at the given coordinates, or *nil* if invalid. + +* ``dfhack.maps.getTileFlags(coords)``, or ``getTileFlags(x,y,z)`` + + Returns designation and occupancy references for the given coordinates, or *nil, nil* if invalid. + * ``dfhack.maps.getRegionBiome(region_coord2d)``, or ``getRegionBiome(x,y)`` Returns the biome info struct for the given global map region. diff --git a/Readme.html b/Readme.html index c1d2d0d3c..6df1afcad 100644 --- a/Readme.html +++ b/Readme.html @@ -2494,20 +2494,21 @@ growcrops plump 40This script remove negative thoughts from your dwarves. Very useful against tantrum spirals.
-With a selected unit in 'v' mode, will clear this unit's mind, otherwise -clear all your fort's units minds.
+The script can target a single creature, when used with the him argument, +or the whole fort population, with all.
+To show every bad thought present without actually removing them, run the +script with the -n or --dry-run argument. This can give a quick +hint on what bothers your dwarves the most.
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.
-With the optional -v parameter, the script will dump the negative thoughts -it removed.
+but in the short term your dwarves will get much more joyful. +Internals: the thoughts are set to be very old, so that the game remove them +quickly after you unpause.
Kills any unit of a given race.
With no argument, lists the available races.
-With the special argument 'him', targets only the selected creature.
+With the special argument him, targets only the selected creature.
Any non-dead non-caged unit of the specified race gets its blood_count set to 0, which means immediate death at the next game tick. For creatures such as vampires, also set animal.vanish_countdown to 2.
diff --git a/library/LuaApi.cpp b/library/LuaApi.cpp index 9f380c353..aa6c93c32 100644 --- a/library/LuaApi.cpp +++ b/library/LuaApi.cpp @@ -82,6 +82,7 @@ distribution. #include "df/flow_info.h" #include "df/unit_misc_trait.h" #include "df/proj_itemst.h" +#include "df/itemdef.h" #include