Move base scripts

develop
PeridexisErrant 2015-10-24 15:10:15 +11:00
parent abb882618b
commit ddae19ad8b
56 changed files with 725 additions and 650 deletions

@ -254,11 +254,19 @@ Opens an in-game screen showing DFHack keybindings that are active in the curren
Type ``hotkeys`` into the DFHack console to open the screen, or bind the command to a
globally active hotkey. The default keybinding is ``Ctrl-F1``.
In-game Console
===============
.. _command-prompt:
In-game command prompt
======================
The ``command-prompt`` plugin adds an in-game DFHack terminal, where you
can enter other commands. It's default keybinding is Ctrl-Shift-P.
A one line command prompt in df. Same as entering command into dfhack console. Best
used as a keybinding. Can be called with optional "entry" that will start prompt with
that pre-filled.
.. image:: images/command-prompt.png
Enabling plugins
================
Many plugins can be in a distinct enabled or disabled state. Some of

@ -68,614 +68,3 @@ The following pages document all the standard DFHack scripts.
/scripts/3rdparty/*/*
ban-cooking
===========
A more convenient way to ban cooking various categories of foods than the
kitchen interface. Usage: ``ban-cooking <type>``. Valid types are ``booze``,
``honey``, ``tallow``, ``oil``, and ``seeds`` (non-tree plants with seeds).
.. _binpatch:
binpatch
========
Implements functions for in-memory binpatches. See `binpatches`.
.. _brainwash:
brainwash
=========
Modify the personality traits of the selected dwarf to match an 'ideal'
personality - as stable and reliable as possible. This makes dwarves very
stable, preventing tantrums even after months of misery.
burial
======
Sets all unowned coffins to allow burial. ``burial -pets`` also allows burial
of pets.
.. _command-prompt:
command-prompt
==============
A one line command prompt in df. Same as entering command into dfhack console. Best
used as a keybinding. Can be called with optional "entry" that will start prompt with
that pre-filled.
.. image:: images/command-prompt.png
create-items
============
Spawn arbitrary items under the cursor.
The first argument gives the item category, the second gives the material,
and the optionnal third gives the number of items to create (defaults to 20).
Currently supported item categories: ``boulder``, ``bar``, ``plant``, ``log``,
``web``.
Instead of material, using ``list`` makes the script list eligible materials.
The ``web`` item category will create an uncollected cobweb on the floor.
Note that the script does not enforce anything, and will let you create
boulders of toad blood and stuff like that.
However the ``list`` mode will only show 'normal' materials.
Examples::
create-items boulders COAL_BITUMINOUS 12
create-items plant tail_pig
create-items log list
create-items web CREATURE:SPIDER_CAVE_GIANT:SILK
create-items bar CREATURE:CAT:SOAP
create-items bar adamantine
.. _deathcause:
deathcause
==========
Focus a body part ingame, and this script will display the cause of death of
the creature.
Also works when selecting units from the (``u``) unitlist viewscreen.
dfusion
=======
Interface to a lecacy script system.
.. _digfort:
digfort
=======
A script to designate an area for digging according to a plan in csv format.
This script, inspired from quickfort, can designate an area for digging.
Your plan should be stored in a .csv file like this::
# this is a comment
d;d;u;d;d;skip this tile;d
d;d;d;i
Available tile shapes are named after the 'dig' menu shortcuts:
``d`` for dig, ``u`` for upstairs, ``d`` downstairs, ``i`` updown,
``h`` channel, ``r`` upward ramp, ``x`` remove designation.
Unrecognized characters are ignored (eg the 'skip this tile' in the sample).
Empty lines and data after a ``#`` are ignored as comments.
To skip a row in your design, use a single ``;``.
One comment in the file may contain the phrase ``start(3,5)``. It is interpreted
as an offset for the pattern: instead of starting at the cursor, it will start
3 tiles left and 5 tiles up from the cursor.
The script takes the plan filename, starting from the root df folder (where
``Dwarf Fortress.exe`` is found).
.. _drain-aquifer:
drain-aquifer
=============
Remove all 'aquifer' tag from the map blocks. Irreversible.
.. _elevate-mental:
elevate-mental
==============
Set all mental attributes of a dwarf to 2600, which is very high.
Other numbers can be passed as an argument: ``elevate-mental 100``
for example would make the dwarf very stupid indeed.
.. _elevate-physical:
elevate-physical
================
As for elevate-mental, but for physical traits. High is good for soldiers,
while having an ineffective hammerer can be useful too...
.. _exportlegends:
exportlegends
=============
Controls legends mode to export data - especially useful to set-and-forget large
worlds, or when you want a map of every site when there are several hundred.
The 'info' option exports more data than is possible in vanilla, to a
``region-date-legends_plus.xml`` file developed to extend the World
Viewer utility and potentially compatible with others.
Options:
:info: Exports the world/gen info, the legends XML, and a custom XML with more information
:sites: Exports all available site maps
:maps: Exports all seventeen detailed maps
:all: Equivalent to calling all of the above, in that order
exterminate
===========
Kills any unit of a given race.
With no argument, lists the available races and count eligible targets.
With the special argument ``him``, targets only the selected creature.
With the special argument ``undead``, targets all undeads on the map,
regardless of their race.
When specifying a race, a caste can be specified to further restrict the
targeting. To do that, append and colon and the caste name after the race.
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, it also sets animal.vanish_countdown to 2.
An alternate mode is selected by adding a 2nd argument to the command,
``magma``. 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 on birds is not recommended.)
Will target any unit on a revealed tile of the map, including ambushers,
but ignore caged/chained creatures.
Ex::
exterminate gob
exterminate gob:male
To kill a single creature, select the unit with the 'v' cursor and::
exterminate him
To purify all elves on the map with fire (may have side-effects)::
exterminate elve magma
fixnaked
========
Removes all unhappy thoughts due to lack of clothing.
.. _fix-ster:
fix-ster
========
Utilizes the orientation tag to either fix infertile creatures or inflict
infertility on creatures that you do not want to breed. Usage::
fix-ster [fert|ster] [all|animals|only:<creature>]
``fert`` or ``ster`` is a required argument; whether to make the target fertile
or sterile. Optional arguments specify the target: no argument for the
selected unit, ``all`` for all units on the map, ``animals`` for all non-dwarf
creatures, or ``only:<creature>`` to only process matching creatures.
.. _forum-dwarves:
forum-dwarves
=============
Saves a copy of a text screen, formatted in bbcode for posting to the Bay12 Forums.
Use ``forum-dwarves help`` for more information.
.. _full-heal:
full-heal
=========
Attempts to fully heal the selected unit. ``full-heal -r`` attempts to resurrect the unit.
.. _gaydar:
gaydar
======
Shows the sexual orientation of units, useful for social engineering or checking
the viability of livestock breeding programs. Use ``gaydar -help`` for information
on available filters for orientation, citizenship, species, etc.
growcrops
=========
Instantly grow seeds inside farming plots.
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.
For example, to grow 40 plump helmet spawn::
growcrops plump 40
.. _hfs-pit:
hfs-pit
=======
Creates a pit to the underworld at the cursor.
Takes three arguments: diameter of the pit in tiles, whether to wall off
the pit, and whether to insert stairs. If no arguments are given, the default
is "hfs-pit 1 0 0", ie single-tile wide with no walls or stairs.::
hfs-pit 4 0 1
hfs-pit 2 1 0
First example is a four-across pit with stairs but no walls; second is a
two-across pit with stairs but no walls.
.. _hotkey-notes:
hotkey-notes
============
Lists the key, name, and jump position of your hotkeys in the DFHack console.
item-descriptions
=================
Exports a table with custom description text for every item in the game.
Used by `view-item-info`.
lever
=====
Allow manipulation of in-game levers from the dfhack console.
Can list levers, including state and links, with::
lever list
To queue a job so that a dwarf will pull the lever 42, use ``lever pull 42``.
This is the same as 'q'uerying the building and queue a 'P'ull request.
To magically toggle the lever immediately, use::
lever pull 42 --now
locate-ore
==========
Scan the map for metal ores.
Finds and designate for digging one tile of a specific metal ore.
Only works for native metal ores, does not handle reaction stuff (eg STEEL).
When invoked with the ``list`` argument, lists metal ores available on the map.
Examples::
locate-ore list
locate-ore hematite
locate-ore iron
log-region
==========
When enabled in dfhack.init, each time a fort is loaded identifying information
will be written to the gamelog. Assists in parsing the file if you switch
between forts, and adds information for story-building.
lua
===
There are the following ways to invoke this command:
1. ``lua`` (without any parameters)
This starts an interactive lua interpreter.
2. ``lua -f "filename"`` or ``lua --file "filename"``
This loads and runs the file indicated by filename.
3. ``lua -s ["filename"]`` or ``lua --save ["filename"]``
This loads and runs the file indicated by filename from the save
directory. If the filename is not supplied, it loads "dfhack.lua".
4. ``:lua`` *lua statement...*
Parses and executes the lua statement like the interactive interpreter would.
make-legendary
==============
Makes the selected dwarf legendary in one skill, a group of skills, or all
skills. View groups with ``make-legendary classes``, or all skills with
``make-legendary list``. Use ``make-legendary MINING`` when you need something
dug up, or ``make-legendary all`` when only perfection will do.
make-monarch
============
Make the selected unit King or Queen of your civilisation.
.. _markdown:
markdown
========
Save a copy of a text screen in markdown (for reddit among others).
Use ``markdown help`` for more details.
masspit
=======
Designate all creatures in cages on top of a pit/pond activity zone for pitting.
Works best with an animal stockpile on top of the zone.
Works with a zone number as argument (eg ``Activity Zone #6`` -> ``masspit 6``)
or with the game cursor on top of the area.
multicmd
========
Run multiple dfhack commands. The argument is split around the
character ; and all parts are run sequentially as independent
dfhack commands. Useful for hotkeys.
Example::
multicmd locate-ore iron ; digv
points
======
Sets available points at the embark screen to the specified number. Eg.
``points 1000000`` would allow you to buy everything, or ``points 0`` would
make life quite difficult.
.. _position:
position
========
Reports the current time: date, clock time, month, and season. Also reports
location: z-level, cursor position, window size, and mouse location.
pref-adjust
===========
A two-stage script: ``pref-adjust clear`` removes preferences from all dwarves,
and ``pref-adjust`` inserts an 'ideal' set which is easy to satisfy::
Feb Idashzefon likes wild strawberries for their vivid red color, fisher berries
for their round shape, prickle berries for their precise thorns, plump helmets
for their rounded tops, prepared meals, plants, drinks, doors, thrones, tables and
beds. When possible, she prefers to consume wild strawberries, fisher berries,
prickle berries, plump helmets, strawberry wine, fisher berry wine, prickle berry
wine, and dwarven wine.
.. _putontable:
putontable
==========
Makes item appear on the table, like in adventure mode shops. Arguments: '-a'
or '--all' for all items.
quicksave
=========
If called in dwarf mode, makes DF immediately auto-save the game by setting a flag
normally used in seasonal auto-save.
region-pops
===========
Show or modify the populations of animals in the region.
Usage:
:region-pops list [pattern]:
Lists encountered populations of the region, possibly restricted by pattern.
:region-pops list-all [pattern]:
Lists all populations of the region.
:region-pops boost <TOKEN> <factor>:
Multiply all populations of TOKEN by factor.
If the factor is greater than one, increases the
population, otherwise decreases it.
:region-pops boost-all <pattern> <factor>:
Same as above, but match using a pattern acceptable to list.
:region-pops incr <TOKEN> <factor>:
Augment (or diminish) all populations of TOKEN by factor (additive).
:region-pops incr-all <pattern> <factor>:
Same as above, but match using a pattern acceptable to list.
.. _rejuvenate:
rejuvenate
==========
Set the age of the selected dwarf to 20 years. Useful if valuable citizens are
getting old, or there are too many babies around...
.. _remove-stress:
remove-stress
=============
Sets stress to -1,000,000; the normal range is 0 to 500,000 with very stable or
very stressed dwarves taking on negative or greater values respectively.
Applies to the selected unit, or use "remove-stress -all" to apply to all units.
remove-wear
===========
Sets the wear on all items in your fort to zero.
.. _repeat:
repeat
======
Repeatedly calls a lua script at the specified interval.
This allows neat background changes to the function of the game, especially when
invoked from an init file. For detailed usage instructions, use ``repeat -help``.
Usage examples::
repeat -name jim -time delay -timeUnits units -printResult true -command [ printArgs 3 1 2 ]
repeat -time 1 -timeUnits months -command [ multicmd cleanowned scattered x; clean all ] -name clean
The first example is abstract; the second will regularly remove all contaminants
and worn items from the game.
``-name`` sets the name for the purposes of cancelling and making sure you don't schedule the
same repeating event twice. If not specified, it's set to the first argument after ``-command``.
``-time delay -timeUnits units``; delay is some positive integer, and units is some valid time
unit for ``dfhack.timeout(delay,timeUnits,function)``. ``-command [ ... ]`` specifies the
command to be run.
setfps
======
Run ``setfps <number>`` to set the FPS cap at runtime, in case you want to watch
combat in slow motion or something :)
.. _show-unit-syndromes:
show-unit-syndromes
===================
Show syndromes affecting units and the remaining and maximum duration, along
with (optionally) substantial detail on the effects.
Use one or more of the following options:
:showall: Show units even if not affected by any syndrome
:showeffects: Show detailed effects of each syndrome
:showdisplayeffects: Show effects that only change the look of the unit
:ignorehiddencurse: Hide syndromes the user should not be able to know about (TODO)
:selected: Show selected unit
:dwarves: Show dwarves
:livestock: Show livestock
:wildanimals: Show wild animals
:hostile: Show hostiles (e.g. invaders, thieves, forgotten beasts etc)
:world: Show all defined syndromes in the world
:export: ``export:<filename>`` sends output to the given file, showing all
syndromes affecting each unit with the maximum and present duration.
.. _siren:
siren
=====
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.
soundsense-season
=================
It is a well known issue that Soundsense cannot detect the correct
current season when a savegame is loaded and has to play random
season music until a season switch occurs.
This script registers a hook that prints the appropriate string
to gamelog.txt on every map load to fix this. For best results
call the script from ``dfhack.init``.
source
======
Create an infinite magma or water source or drain on a tile.
This script registers a map tile as a liquid source, and every 12 game ticks
that tile receives or remove 1 new unit of flow based on the configuration.
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::
source add [magma|water] [0-7]
The number argument is the target liquid level (0 = drain, 7 = source).
To add more than 1 unit everytime, call the command again on the same spot.
To delete one source, place the cursor over its tile and use ``source delete``.
To remove all existing sources, call ``source clear``.
The ``list`` argument shows all existing sources.
Examples::
source add water - water source
source add magma 7 - magma source
source add water 0 - water drain
startdwarf
==========
Use at the embark screen to embark with the specified number of dwarves. Eg.
``startdwarf 500`` would lead to a severe food shortage and FPS issues, while
``startdwarf 10`` would just allow a few more warm bodies to dig in.
The number must be 7 or greater.
stripcaged
==========
For dumping items inside cages. Will mark selected items for dumping, then
a dwarf may come and actually dump it. See also `autodump`.
With the ``items`` argument, only dumps items laying in the cage, excluding
stuff worn by caged creatures. ``weapons`` will dump worn weapons, ``armor``
will dump everything worn by caged creatures (including armor and clothing),
and ``all`` will dump everything, on a creature or not.
``stripcaged list`` will display on the dfhack console the list of all cages
and their item content.
Without further arguments, all commands work on all cages and animal traps on
the map. With the ``here`` argument, considers only the in-game selected cage
(or the cage under the game cursor). To target only specific cages, you can
alternatively pass cage IDs as arguments::
stripcaged weapons 25321 34228
.. _superdwarf:
superdwarf
==========
Similar to `fastdwarf`, per-creature.
To make any creature superfast, target it ingame using 'v' and::
superdwarf add
Other options available: ``del``, ``clear``, ``list``.
This script also shortens the 'sleeping' and 'on break' periods of targets.
.. _teleport:
teleport
========
Teleports a unit to given coordinates.
Examples::
teleport -showunitid - prints unitid beneath cursor
teleport -showpos - prints coordinates beneath cursor
teleport -unit 1234 -x 56 -y 115 -z 26 - teleports unit 1234 to 56,115,26
undump-buildings
================
Undesignates building base materials for dumping.
.. _unsuspend:
unsuspend
=========
Unsuspend jobs in workshops, on a one-off basis. See `autounsuspend`
for regular use.
.. _view-item-info:
view-item-info
==============
A script to extend the item or unit viewscreen with additional information
including a custom description of each item (when available), and properties
such as material statistics, weapon attacks, armor effectiveness, and more.
The associated script ``item-descriptions.lua`` supplies custom descriptions
of items. Individual descriptions can be added or overridden by a similar
script ``raw/scripts/more-item-descriptions.lua``. Both work as sparse lists,
so missing items simply go undescribed if not defined in the fallback.
warn-starving
=============
If any (live) units are starving, very thirsty, or very drowsy, the game will
be paused and a warning shown and logged to the console. Use with the
`repeat` command for regular checks.
Use ``warn-starving all`` to display a list of all problematic units.

@ -1,4 +1,13 @@
# convenient way to ban cooking categories of food
=begin
ban-cooking
===========
A more convenient way to ban cooking various categories of foods than the
kitchen interface. Usage: ``ban-cooking <type>``. Valid types are ``booze``,
``honey``, ``tallow``, ``oil``, and ``seeds`` (non-tree plants with seeds).
=end
already_banned = {}
kitchen = df.ui.kitchen

@ -1,4 +1,11 @@
-- Apply or remove binary patches at runtime.
--[[=begin
binpatch
========
Implements functions for in-memory binpatches. See `binpatches`.
=end]]
local bp = require('binpatch')

@ -1,6 +1,15 @@
-- This script will brainwash a dwarf, modifying their personality
-- usage is: target a unit in DF, and execute this script in dfhack
-- by vjek
--[[=begin
brainwash
=========
Modify the personality traits of the selected dwarf to match an 'ideal'
personality - as stable and reliable as possible. This makes dwarves very
stable, preventing tantrums even after months of misery.
=end]]
function brainwash_unit(profile)
local i,unit_name

@ -1,5 +1,13 @@
-- allows burial in unowned coffins
-- by Putnam https://gist.github.com/Putnam3145/e7031588f4d9b24b9dda
--[[=begin
burial
======
Sets all unowned coffins to allow burial. ``burial -pets`` also allows burial
of pets.
=end]]
local utils=require('utils')

@ -1,4 +1,34 @@
# create first necessity items under cursor
=begin
create-items
============
Spawn items under the cursor, to get your fortress started.
The first argument gives the item category, the second gives the material,
and the optionnal third gives the number of items to create (defaults to 20).
Currently supported item categories: ``boulder``, ``bar``, ``plant``, ``log``,
``web``.
Instead of material, using ``list`` makes the script list eligible materials.
The ``web`` item category will create an uncollected cobweb on the floor.
Note that the script does not enforce anything, and will let you create
boulders of toad blood and stuff like that.
However the ``list`` mode will only show 'normal' materials.
Examples::
create-items boulders COAL_BITUMINOUS 12
create-items plant tail_pig
create-items log list
create-items web CREATURE:SPIDER_CAVE_GIANT:SILK
create-items bar CREATURE:CAT:SOAP
create-items bar adamantine
=end
category = $script_args[0] || 'help'
mat_raw = $script_args[1] || 'list'

@ -1,4 +1,12 @@
# show death cause of a creature
=begin
deathcause
==========
Select a body part ingame, or a unit from the :kbd:`u` unit list, and this
script will display the cause of death of the creature.
=end
def display_death_event(e)
str = "The #{e.victim_hf_tg.race_tg.name[0]} #{e.victim_hf_tg.name} died in year #{e.year}"

@ -1,4 +1,12 @@
-- a collection of misc lua scripts
--[[=begin
dfusion
=======
Interface to a lecacy script system.
=end]]
local dfu=require("plugins.dfusion")
local myos=dfhack.getOSType()
args={...}

@ -1,4 +1,33 @@
# designate an area for digging according to a plan in csv format
=begin
digfort
=======
A script to designate an area for digging according to a plan in csv format.
This script, inspired from quickfort, can designate an area for digging.
Your plan should be stored in a .csv file like this::
# this is a comment
d;d;u;d;d;skip this tile;d
d;d;d;i
Available tile shapes are named after the 'dig' menu shortcuts:
``d`` for dig, ``u`` for upstairs, ``d`` downstairs, ``i`` updown,
``h`` channel, ``r`` upward ramp, ``x`` remove designation.
Unrecognized characters are ignored (eg the 'skip this tile' in the sample).
Empty lines and data after a ``#`` are ignored as comments.
To skip a row in your design, use a single ``;``.
One comment in the file may contain the phrase ``start(3,5)``. It is interpreted
as an offset for the pattern: instead of starting at the cursor, it will start
3 tiles left and 5 tiles up from the cursor.
The script takes the plan filename, starting from the root df folder (where
``Dwarf Fortress.exe`` is found).
=end
fname = $script_args[0].to_s

@ -1,4 +1,11 @@
-- Remove all aquifers from the map
--[[=begin
drain-aquifer
=============
Remove all 'aquifer' tag from the map blocks. Irreversible.
=end]]
local function drain()
local layers = {}

@ -1,7 +1,14 @@
-- This script will elevate all the mental attributes of a unit
-- usage is: target a unit in DF, and execute this script in dfhack
-- all physical attributes will be set to whatever the max value is
-- by vjek
--[[=begin
elevate-mental
==============
Set all mental attributes of the selected dwarf to 2600, which is very high.
Numbers between 0 and 5000 can be passed as an argument: ``elevate-mental 100``
for example would make the dwarf very stupid indeed.
=end]]
function ElevateMentalAttributes(value)
unit=dfhack.gui.getSelectedUnit()

@ -1,7 +1,13 @@
-- This script will elevate all the physical attributes of a unit
-- usage is: target a unit in DF, and execute this script in dfhack
-- all physical attributes will be set to whatever the max value is
-- by vjek
--[[=begin
elevate-physical
================
As for elevate-mental, but for physical traits. High is good for soldiers,
while having an ineffective hammerer can be useful too...
=end]]
function ElevatePhysicalAttributes(value)
unit=dfhack.gui.getSelectedUnit()

@ -1,5 +1,23 @@
-- Export everything from legends mode
-- Valid args: "all", "info", "maps", "sites"
--[[=begin
exportlegends
=============
Controls legends mode to export data - especially useful to set-and-forget large
worlds, or when you want a map of every site when there are several hundred.
The 'info' option exports more data than is possible in vanilla, to a
:file:`region-date-legends_plus.xml` file developed to extend the World
Viewer utility and potentially compatible with others.
Options:
:info: Exports the world/gen info, the legends XML, and a custom XML with more information
:sites: Exports all available site maps
:maps: Exports all seventeen detailed maps
:all: Equivalent to calling all of the above, in that order
=end]]
gui = require 'gui'
local args = {...}

@ -1,7 +1,48 @@
# exterminate creatures
=begin
exterminate
===========
Kills any unit of a given race.
With no argument, lists the available races and count eligible targets.
With the special argument ``him``, targets only the selected creature.
With the special argument ``undead``, targets all undeads on the map,
regardless of their race.
When specifying a race, a caste can be specified to further restrict the
targeting. To do that, append and colon and the caste name after the race.
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, it also sets animal.vanish_countdown to 2.
An alternate mode is selected by adding a 2nd argument to the command,
``magma``. 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 on birds is not recommended.) The final alternate mode
is ``butcher``, which marks them for butchering but does not kill.
Will target any unit on a revealed tile of the map, including ambushers,
but ignore caged/chained creatures.
Ex::
exterminate gob
exterminate gob:male
To kill a single creature, select the unit with the 'v' cursor and::
exterminate him
To purify all elves on the map with fire (may have side-effects)::
exterminate elve magma
=end
# race = name of the race to eradicate, use 'him' to target only the selected creature
# use 'undead' to target all undeads
race = $script_args[0]
# if the 2nd parameter is 'magma', magma rain for the targets instead of instant death

@ -3,20 +3,21 @@
-- original author: Tacomagic
-- minor fixes by PeridexisErrant, Lethosor
--@ module = true
--[[=begin
--[[
This script utilizes the orientation tag to either fix infertile creatures
or inflict infertility on creatures that you do not want to breed
fix-ster
========
Utilizes the orientation tag to either fix infertile creatures or inflict
infertility on creatures that you do not want to breed. Usage::
Required arg:
fert: sets the flag to assure creature(s) are fertile
ster: sets the flag to assure creature(s) are sterile
Optional args:
<no arg> the script will only process the currently selected creature
all: process all creatures currently on the map
animals: processes everything but dwarves on the map
only:<creature>: processes all of the creatures matching the specified creature on the map
]]--
fix-ster [fert|ster] [all|animals|only:<creature>]
``fert`` or ``ster`` is a required argument; whether to make the target fertile
or sterile. Optional arguments specify the target: no argument for the
selected unit, ``all`` for all units on the map, ``animals`` for all non-dwarf
creatures, or ``only:<creature>`` to only process matching creatures.
=end]]
function changeorient(unit, ori)
--Sets the fertility flag based on gender.

@ -1,4 +1,11 @@
--removes unhappy thoughts due to lack of clothing
--[[=begin
fixnaked
========
Removes all unhappy thoughts due to lack of clothing.
=end]]
function fixnaked()
local total_fixed = 0

@ -2,6 +2,14 @@
-- Save a copy of a text screen for the DF forums. Use 'forumdwarves help' for more details.
-- original author: Caldfir
-- edited by expwnent, Mchl
--[[=begin
forum-dwarves
=============
Saves a copy of a text screen, formatted in bbcode for posting to the Bay12 Forums.
Use ``forum-dwarves help`` for more information.
=end]]
local args = {...}

@ -2,7 +2,13 @@
--author Kurik Amudnil, Urist DaVinci
--edited by expwnent
-- attempt to fully heal a selected unit, option -r to attempt to resurrect the unit
--[[=begin
full-heal
=========
Attempts to fully heal the selected unit. ``full-heal -r`` attempts to resurrect the unit.
=end]]
local utils=require('utils')

@ -1,4 +1,13 @@
local utils = require('utils')
--[[=begin
gaydar
======
Shows the sexual orientation of units, useful for social engineering or checking
the viability of livestock breeding programs. Use ``gaydar -help`` for information
on available filters for orientation, citizenship, species, etc.
=end]]
validArgs = utils.invert({
'all',

@ -1,4 +1,19 @@
# grow crops in farm plots. ex: growcrops helmet_plump 20
=begin
growcrops
=========
Instantly grow seeds inside farming plots.
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. Set the number with a 2nd argument.
For example, to grow 40 plump helmet spawn::
growcrops plump 40
=end
material = $script_args[0]
count_max = $script_args[1].to_i

@ -1,5 +1,22 @@
-- Creates a pit under the target leading straight to the Underworld. Type '?' for help.
-- Based on script by IndigoFenix, @ https://gist.github.com/IndigoFenix/8776696
--[[=begin
hfs-pit
=======
Creates a pit to the underworld at the cursor.
Takes three arguments: diameter of the pit in tiles, whether to wall off
the pit, and whether to insert stairs. If no arguments are given, the default
is ``hfs-pit 1 0 0``, ie single-tile wide with no walls or stairs.::
hfs-pit 4 0 1
hfs-pit 2 1 0
First example is a four-across pit with stairs but no walls; second is a
two-across pit with stairs but no walls.
=end]]
args={...}

@ -1,4 +1,11 @@
-- prints info on assigned hotkeys to the console
--[[=begin
hotkey-notes
============
Lists the key, name, and jump position of your hotkeys in the DFHack console.
=end]]
for i=1, #df.global.ui.main.hotkeys do
local hk = df.global.ui.main.hotkeys[i-1]

@ -1,5 +1,14 @@
-- Holds custom descriptions for view-item-info
-- By PeridexisErrant
--[[=begin
item-descriptions
=================
Exports a table with custom description text for every item in the game.
Used by `view-item-info`; see instructions there for how to override
for mods.
=end]]
-- Each line near the bottom has 53 characters of room until
-- it starts clipping over the UI in an ugly fashion.

@ -1,4 +1,22 @@
# control your levers from the dfhack console
=begin
lever
=====
Allow manipulation of in-game levers from the dfhack console.
Can list levers, including state and links, with::
lever list
To queue a job so that a dwarf will pull the lever 42, use ``lever pull 42``.
This is the same as :kbd:`q` querying the building and queue a :kbd:`P` pull request.
To magically toggle the lever immediately, use::
lever pull 42 --now
=end
def lever_pull_job(bld)
ref = DFHack::GeneralRefBuildingHolderst.cpp_new

@ -1,4 +1,22 @@
# scan the map for ore veins
=begin
locate-ore
==========
Scan the map for metal ores.
Finds and designate for digging one tile of a specific metal ore.
Only works for native metal ores, does not handle reaction stuff (eg STEEL).
When invoked with the ``list`` argument, lists metal ores available on the map.
Examples::
locate-ore list
locate-ore hematite
locate-ore iron
=end
target_ore = $script_args[0]

@ -1,5 +1,14 @@
-- On map load writes information about the loaded region to gamelog.txt
-- By Kurik Amudnil and Warmist (http://www.bay12forums.com/smf/index.php?topic=91166.msg4467072#msg4467072)
--[[=begin
log-region
==========
When enabled in :file:`dfhack.init`, each time a fort is loaded identifying information
will be written to the gamelog. Assists in parsing the file if you switch
between forts, and adds information for story-building.
=end]]
local function write_gamelog(msg)
local log = io.open('gamelog.txt', 'a')

@ -1,4 +1,28 @@
-- Execute lua commands interactively or from files.
--[[=begin
lua
===
There are the following ways to invoke this command:
1. ``lua`` (without any parameters)
This starts an interactive lua interpreter.
2. ``lua -f "filename"`` or ``lua --file "filename"``
This loads and runs the file indicated by filename.
3. ``lua -s ["filename"]`` or ``lua --save ["filename"]``
This loads and runs the file indicated by filename from the save
directory. If the filename is not supplied, it loads "dfhack.lua".
4. ``:lua`` *lua statement...*
Parses and executes the lua statement like the interactive interpreter would.
=end]]
local args={...}
local cmd = args[1]

@ -1,8 +1,16 @@
-- This script will modify a skill or the skills of a single unit
-- usage is: target a unit in DF, and execute this script in dfhack
-- the skill will be increased to 20 (Legendary +5)
-- arguments 'list', 'classes' and 'all' added
-- by vjek
--[[=begin
make-legendary
==============
Makes the selected dwarf legendary in one skill, a group of skills, or all
skills. View groups with ``make-legendary classes``, or all skills with
``make-legendary list``. Use ``make-legendary MINING`` when you need something
dug up, or ``make-legendary all`` when only perfection will do.
=end]]
-- this function will return the number of elements, starting at zero.
-- useful for counting things where #foo doesn't work

@ -1,4 +1,12 @@
--set target unit as king/queen
--[[=begin
make-monarch
============
Make the selected unit King or Queen of your civilisation.
=end]]
local unit=dfhack.gui.getSelectedUnit()
if not unit then qerror("No unit selected") end
local newfig=dfhack.units.getNemesis(unit).figure

@ -1,6 +1,14 @@
-- Save a copy of a text screen in markdown (for reddit among others). Use 'markdown help' for more details.
-- This is a derivatiwe work based upon scripts/forum-dwarves.lua by Caldfir and expwnent
-- Adapted for markdown by Mchl https://github.com/Mchl
--[[=begin
markdown
========
Save a copy of a text screen in markdown (for reddit among others).
Use ``markdown help`` for more details.
=end]]
local args = {...}

@ -1,4 +1,15 @@
# pit all caged creatures in a zone
=begin
masspit
=======
Designate all creatures in cages on top of a pit/pond activity zone for pitting.
Works best with an animal stockpile on top of the zone.
Works with a zone number as argument (eg ``Activity Zone #6`` -> ``masspit 6``)
or with the game cursor on top of the area.
=end
case $script_args[0]
when '?', 'help'

@ -1,4 +1,16 @@
# run many dfhack commands separated by ;
# ex: multicmd locate-ore IRON ; digv ; digcircle 16
=begin
multicmd
========
Run multiple dfhack commands. The argument is split around the
character ; and all parts are run sequentially as independent
dfhack commands. Useful for hotkeys.
Example::
multicmd locate-ore IRON ; digv ; digcircle 16
=end
$script_args.join(' ').split(/\s*;\s*/).each { |cmd| df.dfhack_run cmd }

@ -1,3 +1,13 @@
-- by Meph
-- http://www.bay12forums.com/smf/index.php?topic=135506.msg4925005#msg4925005
--[[=begin
points
======
Sets available points at the embark screen to the specified number. Eg.
``points 1000000`` would allow you to buy everything, or ``points 0`` would
make life quite difficult.
=end]]
df.global.world.worldgen.worldgen_parms.embark_points=tonumber(...)

@ -1,4 +1,12 @@
--prints current time and position
--[[=begin
position
========
Reports the current time: date, clock time, month, and season. Also reports
location: z-level, cursor position, window size, and mouse location.
=end]]
local months = {
'Granite, in early Spring.',

@ -1,7 +1,20 @@
-- Adjust all preferences of all dwarves in play
-- all preferences are cleared, then set
-- WARNING: USING THIS SCRIPT WILL ADJUST ALL DWARVES IN PLAY!
-- by vjek
--[[=begin
pref-adjust
===========
A two-stage script: ``pref-adjust clear`` removes preferences from all dwarves,
and ``pref-adjust`` inserts an 'ideal' set which is easy to satisfy::
Feb Idashzefon likes wild strawberries for their vivid red color, fisher berries
for their round shape, prickle berries for their precise thorns, plump helmets
for their rounded tops, prepared meals, plants, drinks, doors, thrones, tables and
beds. When possible, she prefers to consume wild strawberries, fisher berries,
prickle berries, plump helmets, strawberry wine, fisher berry wine, prickle berry
wine, and dwarven wine.
=end]]
-- ---------------------------------------------------------------------------
function brainwash_unit(unit)

@ -1,4 +1,13 @@
-- Makes item appear on the table (just like in shops). '-a' or '--all' for all items.
-- Makes item appear on the table (just like in shops)
--[[=begin
putontable
==========
Makes item appear on the table, like in adventure mode shops.
Arguments: ``-a`` or ``--all`` for all items.
=end]]
local pos=df.global.cursor
local args={...}
local doall

@ -1,4 +1,12 @@
-- Makes the game immediately save the state.
--[[=begin
quicksave
=========
If called in dwarf mode, makes DF immediately auto-save the game by setting a flag
normally used in seasonal auto-save.
=end]]
if not dfhack.isMapLoaded() then
qerror("World and map aren't loaded.")

@ -1,4 +1,28 @@
-- Shows populations of animals in the region, and allows tweaking them.
--[[=begin
region-pops
===========
Show or modify the populations of animals in the region.
Usage:
:region-pops list [pattern]:
Lists encountered populations of the region, possibly restricted by pattern.
:region-pops list-all [pattern]:
Lists all populations of the region.
:region-pops boost <TOKEN> <factor>:
Multiply all populations of TOKEN by factor.
If the factor is greater than one, increases the
population, otherwise decreases it.
:region-pops boost-all <pattern> <factor>:
Same as above, but match using a pattern acceptable to list.
:region-pops incr <TOKEN> <factor>:
Augment (or diminish) all populations of TOKEN by factor (additive).
:region-pops incr-all <pattern> <factor>:
Same as above, but match using a pattern acceptable to list.
=end]]
local utils = require 'utils'

@ -1,7 +1,13 @@
-- This script will make any "old" dwarf 20 years old
-- usage is: target a unit in DF, and execute this script in dfhack
-- the target will be changed to 20 years old
-- make the selected dwarf 20 years old
-- by vjek
--[[=begin
rejuvenate
==========
Set the age of the selected dwarf to 20 years. Useful if valuable citizens are
getting old, or there are too many babies around...
=end]]
function rejuvenate()
local current_year,newbirthyear

@ -1,7 +1,14 @@
-- Sets stress to negative one million
-- With unit selected, affects that unit. Use "remove-stress all" to affect all units.
--By Putnam; http://www.bay12forums.com/smf/index.php?topic=139553.msg5820486#msg5820486
--[[=begin
remove-stress
=============
Sets stress to -1,000,000; the normal range is 0 to 500,000 with very stable or
very stressed dwarves taking on negative or greater values respectively.
Applies to the selected unit, or use "remove-stress -all" to apply to all units.
=end]]
local utils = require 'utils'

@ -2,6 +2,13 @@
-- Resets all items in your fort to 0 wear
-- original author: Laggy
-- edited by expwnent
--[[=begin
remove-wear
===========
Sets the wear on all items in your fort to zero.
=end]]
local args = {...}

@ -3,6 +3,30 @@
-- repeat -help for details
-- author expwnent
-- vaguely based on a script by Putnam
--[[=begin
repeat
======
Repeatedly calls a lua script at the specified interval.
This allows neat background changes to the function of the game, especially when
invoked from an init file. For detailed usage instructions, use ``repeat -help``.
Usage examples::
repeat -name jim -time delay -timeUnits units -printResult true -command [ printArgs 3 1 2 ]
repeat -time 1 -timeUnits months -command [ multicmd cleanowned scattered x; clean all ] -name clean
The first example is abstract; the second will regularly remove all contaminants
and worn items from the game.
``-name`` sets the name for the purposes of cancelling and making sure you don't schedule the
same repeating event twice. If not specified, it's set to the first argument after ``-command``.
``-time delay -timeUnits units``; delay is some positive integer, and units is some valid time
unit for ``dfhack.timeout(delay,timeUnits,function)``. ``-command [ ... ]`` specifies the
command to be run.
=end]]
local repeatUtil = require 'repeat-util'
local utils = require 'utils'

@ -1,4 +1,12 @@
-- Set the FPS cap at runtime.
--[[=begin
setfps
======
Run ``setfps <number>`` to set the FPS cap at runtime, in case you want to watch
combat in slow motion or something.
=end]]
local cap = ...
local capnum = tonumber(cap)

@ -1,6 +1,30 @@
# Show syndromes affecting units and the remaining and maximum duration (v6). Call with help on the command line for further options.
# Show syndromes affecting units and the remaining and maximum duration
# original author: drayath
# edited by expwnent
=begin
show-unit-syndromes
===================
Show syndromes affecting units and the remaining and maximum duration, along
with (optionally) substantial detail on the effects.
Use one or more of the following options:
:help: Show the help message
:showall: Show units even if not affected by any syndrome
:showeffects: Show detailed effects of each syndrome
:showdisplayeffects: Show effects that only change the look of the unit
:ignorehiddencurse: Hide syndromes the user should not be able to know about (TODO)
:selected: Show selected unit
:dwarves: Show dwarves
:livestock: Show livestock
:wildanimals: Show wild animals
:hostile: Show hostiles (e.g. invaders, thieves, forgotten beasts etc)
:world: Show all defined syndromes in the world
:export: ``export:<filename>`` sends output to the given file, showing all
syndromes affecting each unit with the maximum and present duration.
=end
#TODO: When showing effects on a unit, show the actual change to the unit
# E.g. if +150%, +500 strength show actual total bonus based on the unit stats.

@ -1,4 +1,15 @@
-- Wakes up the sleeping, breaks up parties and stops breaks.
--[[=begin
siren
=====
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.
=end]]
local utils = require 'utils'

@ -1,4 +1,17 @@
-- On map load writes the current season to gamelog.txt
--[[=begin
soundsense-season
=================
It is a well known issue that Soundsense cannot detect the correct
current season when a savegame is loaded and has to play random
season music until a season switch occurs.
This script registers a hook that prints the appropriate string
to :file:`gamelog.txt` on every map load to fix this. For best results
call the script from :file:`dfhack.init`.
=end]]
local seasons = {
[-1] = 'Nothing', -- worldgen

@ -1,4 +1,34 @@
# create an infinite magma/water source/drain at the cursor
=begin
source
======
Create an infinite magma or water source or drain on a tile.
This script registers a map tile as a liquid source, and every 12 game ticks
that tile receives or remove 1 new unit of flow based on the configuration.
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::
source add [magma|water] [0-7]
The number argument is the target liquid level (0 = drain, 7 = source).
To add more than 1 unit everytime, call the command again on the same spot.
To delete one source, place the cursor over its tile and use ``source delete``.
To remove all existing sources, call ``source clear``.
The ``list`` argument shows all existing sources.
Examples::
source add water - water source
source add magma 7 - magma source
source add water 0 - water drain
=end
$sources ||= []

@ -1,4 +1,14 @@
# patch start dwarf count
=begin
startdwarf
==========
Use at the embark screen to embark with the specified number of dwarves. Eg.
``startdwarf 500`` would lead to a severe food shortage and FPS issues, while
``startdwarf 10`` would just allow a few more warm bodies to dig in.
The number must be 7 or greater.
=end
nr = $script_args[0].to_i

@ -1,4 +1,27 @@
# mark stuff inside of cages for dumping.
=begin
stripcaged
==========
For dumping items inside cages. Will mark selected items for dumping, then
a dwarf may come and actually dump it. See also `autodump`.
With the ``items`` argument, only dumps items laying in the cage, excluding
stuff worn by caged creatures. ``weapons`` will dump worn weapons, ``armor``
will dump everything worn by caged creatures (including armor and clothing),
and ``all`` will dump everything, on a creature or not.
``stripcaged list`` will display on the dfhack console the list of all cages
and their item content.
Without further arguments, all commands work on all cages and animal traps on
the map. With the ``here`` argument, considers only the in-game selected cage
(or the cage under the game cursor). To target only specific cages, you can
alternatively pass cage IDs as arguments::
stripcaged weapons 25321 34228
=end
def plural(nr, name)
# '1 cage' / '4 cages'

@ -1,4 +1,19 @@
# give super-dwarven speed to an unit
=begin
superdwarf
==========
Similar to `fastdwarf`, per-creature.
To make any creature superfast, target it ingame using 'v' and::
superdwarf add
Other options available: ``del``, ``clear``, ``list``.
This script also shortens the 'sleeping' and 'on break' periods of targets.
=end
$superdwarf_onupdate ||= nil
$superdwarf_ids ||= []

@ -2,6 +2,18 @@
-- teleports a unit to a location
-- author Putnam
-- edited by expwnent
--[[=begin
teleport
========
Teleports a unit to given coordinates. Examples:
:teleport -showunitid: prints unitid beneath cursor
:teleport -showpos: prints coordinates beneath cursor
:teleport -unit 1234 -x 56 -y 115 -z 26:
teleports unit 1234 to 56,115,26
=end]]
function teleport(unit,pos)
local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16]

@ -1,4 +1,12 @@
-- Undesignates building base materials for dumping.
--[[=begin
undump-buildings
================
Undesignates building base materials for dumping.
=end]]
function undump_buildings()
local buildings = df.global.world.buildings.all
local undumped = 0

@ -1,5 +1,13 @@
# un-suspend construction jobs, one time only
# same as "resume all"
=begin
unsuspend
=========
Unsuspend jobs in workshops, on a one-off basis. See `autounsuspend`
for regular use.
=end
joblist = df.world.job_list.next
count = 0

@ -2,14 +2,20 @@
-- Shows information on material properties, weapon or armour stats, and more.
-- By PeridexisErrant, adapted from nb_item_info by Raidau
--@ enable = true
local help = [[=begin
local help = [[Extended Item Viewscreen
view-item-info
==============
A script to extend the item or unit viewscreen with additional information
including properties such as material info, weapon and attack properties,
armor thickness and coverage, and more - including custom item descriptions.]]
including a custom description of each item (when available), and properties
such as material statistics, weapon attacks, armor effectiveness, and more.
The associated script ``item-descriptions.lua`` supplies custom descriptions
of items. Individual descriptions can be added or overridden by a similar
script ``raw/scripts/more-item-descriptions.lua``. Both work as sparse lists,
so missing items simply go undescribed if not defined in the fallback.
vi_label = 'More information (DFHack):'
=end]]
function isInList(list, item, helper)
if not helper then
@ -372,6 +378,7 @@ function AddUsesString (viewscreen,line,indent)
end
function dfhack.onStateChange.item_info (code)
vi_label = 'More information (DFHack):'
if not enabled then return end
if code == SC_VIEWSCREEN_CHANGED and dfhack.isWorldLoaded() then
standard = dfhack.matinfo.find("INORGANIC:IRON").material

@ -1,6 +1,17 @@
-- Pauses the game with a warning if a creature is starving, dehydrated, or very drowsy.
-- By Meneth32, PeridexisErrant, Lethosor
--@ module = true
--[[=begin
warn-starving
=============
If any (live) units are starving, very thirsty, or very drowsy, the game will
be paused and a warning shown and logged to the console. Use with the
`repeat` command for regular checks.
Use ``warn-starving all`` to display a list of all problematic units.
=end]]
starvingUnits = starvingUnits or {}
dehydratedUnits = dehydratedUnits or {}