2015-11-05 06:58:18 -07:00
|
|
|
.. _dfhack-core:
|
|
|
|
|
2015-09-24 22:15:05 -06:00
|
|
|
###########
|
|
|
|
DFHack Core
|
|
|
|
###########
|
2012-09-20 05:38:58 -06:00
|
|
|
|
2020-07-08 00:13:37 -06:00
|
|
|
.. contents:: Contents
|
|
|
|
:local:
|
|
|
|
:depth: 2
|
2016-08-12 03:04:23 -06:00
|
|
|
|
|
|
|
|
|
|
|
Command Implementation
|
|
|
|
======================
|
2015-11-05 06:58:18 -07:00
|
|
|
DFHack commands can be implemented in three ways, all of which
|
|
|
|
are used in the same way:
|
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
:builtin: commands are implemented by the core of DFHack. They manage
|
2020-07-22 00:23:29 -06:00
|
|
|
other DFHack tools, interpret commands, and control basic
|
2015-11-05 17:44:43 -07:00
|
|
|
aspects of DF (force pause or quit).
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
:plugins: are stored in ``hack/plugins/`` and must be compiled with the
|
|
|
|
same version of DFHack. They are less flexible than scripts,
|
2020-07-22 00:23:29 -06:00
|
|
|
but used for complex or ongoing tasks because they run faster.
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
:scripts: are Ruby or Lua scripts stored in ``hack/scripts/``.
|
|
|
|
Because they don't need to be compiled, scripts are
|
|
|
|
more flexible about versions, and easier to distribute.
|
|
|
|
Most third-party DFHack addons are scripts.
|
|
|
|
|
|
|
|
|
2016-08-12 03:04:23 -06:00
|
|
|
Using DFHack Commands
|
|
|
|
=====================
|
|
|
|
DFHack commands can be executed in a number of ways:
|
|
|
|
|
|
|
|
#. Typing the command into the DFHack console (see below)
|
|
|
|
#. From the OS terminal (see below)
|
|
|
|
#. Pressing a key combination set up with `keybinding`
|
|
|
|
#. From one of several `init-files`, automatically
|
|
|
|
#. Using `script` to run a batch of commands from a file
|
|
|
|
|
2016-08-12 21:42:12 -06:00
|
|
|
The DFHack Console
|
|
|
|
------------------
|
2016-08-12 03:04:23 -06:00
|
|
|
The command line has some nice line editing capabilities, including history
|
|
|
|
that's preserved between different runs of DF - use :kbd:`↑` and :kbd:`↓`
|
|
|
|
to go through the history.
|
|
|
|
|
|
|
|
To include whitespace in the argument/s to some command, quote it in
|
|
|
|
double quotes. To include a double quote character, use ``\"``.
|
|
|
|
|
|
|
|
If the first non-whitespace character is ``:``, the command is parsed in
|
|
|
|
an alternative mode. The non-whitespace characters following the ``:`` are
|
|
|
|
the command name, and the remaining part of the line is used verbatim as
|
|
|
|
the first argument. This is very useful for the `lua` and `rb` commands.
|
|
|
|
As an example, the following two command lines are exactly equivalent::
|
|
|
|
|
|
|
|
:foo a b "c d" e f
|
|
|
|
foo "a b \"c d\" e f"
|
|
|
|
|
2016-08-12 21:42:12 -06:00
|
|
|
Using an OS terminal
|
|
|
|
--------------------
|
|
|
|
DFHack commands can be run from an OS terminal at startup, using '+ args',
|
|
|
|
or at any other time using the ``dfhack-run`` executable.
|
2016-08-12 03:04:23 -06:00
|
|
|
|
2016-08-12 21:42:12 -06:00
|
|
|
If DF/DFHack is started with arguments beginning with ``+``, the remaining
|
|
|
|
text is treated as a command in the DFHack console. It is possible to use
|
|
|
|
multiple such commands, which are split on ``+``. For example::
|
2016-08-12 03:04:23 -06:00
|
|
|
|
2016-08-12 21:42:12 -06:00
|
|
|
./dfhack +load-save region1
|
|
|
|
"Dwarf Fortress.exe" +devel/print-args Hello! +enable workflow
|
|
|
|
|
|
|
|
The first example (\*nix), `load-save`, skips the main menu and loads
|
|
|
|
``region1`` immediately. The second (Windows) example prints
|
|
|
|
:guilabel:`Hello!` in the DFHack console, and `enables <enable>` `workflow`.
|
|
|
|
Note that the ``:foo`` syntax for whitespace in arguments is not compatible \
|
|
|
|
with '+ args'.
|
|
|
|
|
|
|
|
|
2018-07-02 22:02:53 -06:00
|
|
|
.. _dfhack-run:
|
|
|
|
|
|
|
|
dfhack-run
|
|
|
|
..........
|
|
|
|
|
2016-08-12 21:42:12 -06:00
|
|
|
If DF and DFHack are already running, calling ``dfhack-run my command``
|
|
|
|
in an external terminal is equivalent to calling ``my command`` in the
|
2020-07-21 21:14:59 -06:00
|
|
|
DFHack console. Direct use of the DFHack console is generally easier,
|
2016-08-12 21:42:12 -06:00
|
|
|
but ``dfhack-run`` can be useful in a variety of circumstances:
|
|
|
|
|
|
|
|
- if the console is unavailable
|
|
|
|
|
|
|
|
- with the init setting ``PRINT_MODE:TEXT``
|
2020-07-22 00:23:29 -06:00
|
|
|
- while running an interactive command (e.g. `liquids` or `tiletypes`)
|
2016-08-12 21:42:12 -06:00
|
|
|
|
|
|
|
- from external programs or scripts
|
|
|
|
- if DF or DFHack are not responding
|
|
|
|
|
|
|
|
Examples::
|
|
|
|
|
|
|
|
./dfhack-run cursecheck
|
2018-07-02 22:02:53 -06:00
|
|
|
dfhack-run kill-lua
|
2016-08-12 21:42:12 -06:00
|
|
|
|
|
|
|
The first (\*nix) example `checks for vampires <cursecheck>`; the
|
2018-07-02 22:02:53 -06:00
|
|
|
second (Windows) example uses `kill-lua` to stop a Lua script.
|
2012-02-04 20:28:20 -07:00
|
|
|
|
2020-07-21 21:14:59 -06:00
|
|
|
.. note::
|
|
|
|
|
|
|
|
``dfhack-run`` attempts to connect to a server on TCP port 5000. If DFHack
|
|
|
|
was unable to start this server, ``dfhack-run`` will not be able to connect.
|
|
|
|
This could happen if you have other software listening on port 5000, or if
|
|
|
|
you have multiple copies of DF running simultaneously. To assign a different
|
|
|
|
port, see `remote-server-config`.
|
|
|
|
|
2015-09-22 07:30:22 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Built-in Commands
|
|
|
|
=================
|
|
|
|
The following commands are provided by the 'core' components
|
2020-07-22 00:23:29 -06:00
|
|
|
of DFHack, rather than plugins or scripts.
|
2015-11-05 06:58:18 -07:00
|
|
|
|
2016-08-12 03:04:23 -06:00
|
|
|
.. contents::
|
|
|
|
:local:
|
2015-11-05 06:58:18 -07:00
|
|
|
|
2017-06-23 10:44:34 -06:00
|
|
|
|
|
|
|
.. _alias:
|
2015-11-05 06:58:18 -07:00
|
|
|
|
2017-06-18 15:39:54 -06:00
|
|
|
alias
|
|
|
|
-----
|
|
|
|
The ``alias`` command allows configuring aliases to other DFHack commands.
|
|
|
|
Aliases are resolved immediately after built-in commands, which means that an
|
|
|
|
alias cannot override a built-in command, but can override a command implemented
|
|
|
|
by a plugin or script.
|
|
|
|
|
|
|
|
Usage:
|
|
|
|
|
|
|
|
:``alias list``: lists all configured aliases
|
|
|
|
:``alias add <name> <command> [arguments...]``: adds an alias
|
|
|
|
:``alias replace <name> <command> [arguments...]``: replaces an existing
|
|
|
|
alias with a new command, or adds the alias if it does not already exist
|
|
|
|
:``alias delete <name>``: removes the specified alias
|
|
|
|
|
|
|
|
Aliases can be given additional arguments when created and invoked, which will
|
|
|
|
be passed to the underlying command in order. An example with `devel/print-args`::
|
|
|
|
|
|
|
|
[DFHack]# alias add pargs devel/print-args example
|
|
|
|
[DFHack]# pargs text
|
|
|
|
example
|
|
|
|
text
|
|
|
|
|
2017-06-23 10:44:34 -06:00
|
|
|
|
|
|
|
.. _cls:
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
cls
|
|
|
|
---
|
|
|
|
Clear the terminal. Does not delete command history.
|
|
|
|
|
|
|
|
|
|
|
|
.. _die:
|
|
|
|
|
|
|
|
die
|
|
|
|
---
|
|
|
|
Instantly kills DF without saving.
|
|
|
|
|
|
|
|
|
|
|
|
.. _disable:
|
|
|
|
|
|
|
|
.. _enable:
|
|
|
|
|
|
|
|
enable
|
|
|
|
------
|
|
|
|
Many plugins can be in a distinct enabled or disabled state. Some of
|
|
|
|
them activate and deactivate automatically depending on the contents
|
|
|
|
of the world raws. Others store their state in world data. However a
|
|
|
|
number of them have to be enabled globally, and the init file is the
|
|
|
|
right place to do it.
|
|
|
|
|
|
|
|
Most such plugins or scripts support the built-in ``enable`` and ``disable``
|
|
|
|
commands. Calling them at any time without arguments prints a list
|
|
|
|
of enabled and disabled plugins, and shows whether that can be changed
|
2020-07-08 21:46:38 -06:00
|
|
|
through the same commands. Passing plugin names to these commands will enable
|
|
|
|
or disable the specified plugins. For example, to enable the `manipulator`
|
|
|
|
plugin::
|
2015-02-15 00:13:58 -07:00
|
|
|
|
2020-07-08 21:46:38 -06:00
|
|
|
enable manipulator
|
|
|
|
|
|
|
|
It is also possible to enable or disable multiple plugins at once::
|
2010-07-19 19:48:09 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
enable manipulator search
|
2010-07-19 19:48:09 -06:00
|
|
|
|
2011-08-07 21:45:35 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _fpause:
|
2011-08-15 00:07:24 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
fpause
|
|
|
|
------
|
|
|
|
Forces DF to pause. This is useful when your FPS drops below 1 and you lose
|
|
|
|
control of the game.
|
2015-09-22 07:30:22 -06:00
|
|
|
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _help:
|
2010-07-19 19:48:09 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
help
|
|
|
|
----
|
|
|
|
Most commands support using the ``help <command>`` built-in command
|
|
|
|
to retrieve further help without having to look at this document.
|
|
|
|
``? <cmd>`` and ``man <cmd>`` are aliases.
|
2015-02-07 17:49:26 -07:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Some commands (including many scripts) instead take ``help`` or ``?``
|
|
|
|
as an option on their command line - ie ``<cmd> help``.
|
2010-07-19 19:48:09 -06:00
|
|
|
|
2011-03-13 12:38:32 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _hide:
|
2011-03-13 12:38:32 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
hide
|
|
|
|
----
|
|
|
|
Hides the DFHack terminal window. Only available on Windows.
|
2011-04-04 03:55:25 -06:00
|
|
|
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _keybinding:
|
2011-03-13 12:38:32 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
keybinding
|
|
|
|
----------
|
|
|
|
To set keybindings, use the built-in ``keybinding`` command. Like any other
|
|
|
|
command it can be used at any time from the console, but bindings are not
|
|
|
|
remembered between runs of the game unless re-created in `dfhack.init`.
|
2011-08-15 00:07:24 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Currently, any combinations of Ctrl/Alt/Shift with A-Z, 0-9, or F1-F12 are supported.
|
2011-08-15 00:07:24 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Possible ways to call the command:
|
2015-09-22 07:30:22 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
``keybinding list <key>``
|
|
|
|
List bindings active for the key combination.
|
|
|
|
``keybinding clear <key> <key>...``
|
|
|
|
Remove bindings for the specified keys.
|
|
|
|
``keybinding add <key> "cmdline" "cmdline"...``
|
|
|
|
Add bindings for the specified key.
|
|
|
|
``keybinding set <key> "cmdline" "cmdline"...``
|
|
|
|
Clear, and then add bindings for the specified key.
|
2012-11-10 23:58:05 -07:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
The ``<key>`` parameter above has the following *case-sensitive* syntax::
|
2012-11-10 23:58:05 -07:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
[Ctrl-][Alt-][Shift-]KEY[@context[|context...]]
|
2012-11-10 23:58:05 -07:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
where the *KEY* part can be any recognized key and [] denote optional parts.
|
2012-11-10 23:58:05 -07:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
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.
|
2012-04-17 17:40:07 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
The ``context`` 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 ``keybinding`` command among other things prints the current context string.
|
2012-04-17 17:40:07 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Only bindings with a ``context`` tag that either matches the current context fully,
|
|
|
|
or is a prefix ending at a ``/`` boundary would be considered for execution, i.e.
|
|
|
|
when in context ``foo/bar/baz``, keybindings restricted to any of ``@foo/bar/baz``,
|
|
|
|
``@foo/bar``, ``@foo`` or none will be active.
|
2012-04-17 17:40:07 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Multiple contexts can be specified by separating them with a
|
|
|
|
pipe (``|``) - for example, ``@foo|bar|baz/foo`` would match
|
|
|
|
anything under ``@foo``, ``@bar``, or ``@baz/foo``.
|
2012-02-05 08:25:06 -07:00
|
|
|
|
2015-10-18 21:16:19 -06:00
|
|
|
Interactive commands like `liquids` cannot be used as hotkeys.
|
2010-07-19 19:48:09 -06:00
|
|
|
|
2011-03-27 08:47:09 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _kill-lua:
|
2015-02-15 00:13:58 -07:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
kill-lua
|
|
|
|
--------
|
|
|
|
Stops any currently-running Lua scripts. By default, scripts can
|
|
|
|
only be interrupted every 256 instructions. Use ``kill-lua force``
|
|
|
|
to interrupt the next instruction.
|
2015-02-15 00:13:58 -07:00
|
|
|
|
2011-08-15 00:07:24 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _load:
|
|
|
|
.. _unload:
|
|
|
|
.. _reload:
|
2015-09-22 07:30:22 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
load
|
|
|
|
----
|
|
|
|
``load``, ``unload``, and ``reload`` control whether a plugin is loaded
|
|
|
|
into memory - note that plugins are loaded but disabled unless you do
|
|
|
|
something. Usage::
|
2015-09-22 07:30:22 -06:00
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
load|unload|reload PLUGIN|(-a|--all)
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
Allows dealing with plugins individually by name, or all at once.
|
|
|
|
|
2020-07-08 21:46:38 -06:00
|
|
|
Note that plugins do not maintain their enabled state if they are reloaded, so
|
|
|
|
you may need to use `enable` to re-enable a plugin after reloading it.
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
.. _ls:
|
|
|
|
|
|
|
|
ls
|
|
|
|
--
|
|
|
|
``ls`` does not list files like the Unix command, but rather
|
|
|
|
available commands - first built in commands, then plugins,
|
|
|
|
and scripts at the end. Usage:
|
|
|
|
|
|
|
|
:ls -a: Also list scripts in subdirectories of ``hack/scripts/``,
|
|
|
|
which are generally not intended for direct use.
|
|
|
|
:ls <plugin>: List subcommands for the given plugin.
|
|
|
|
|
|
|
|
|
|
|
|
.. _plug:
|
|
|
|
|
|
|
|
plug
|
|
|
|
----
|
2015-11-05 17:44:43 -07:00
|
|
|
Lists available plugins, including their state and detailed description.
|
2015-11-05 06:58:18 -07:00
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
``plug``
|
|
|
|
Lists available plugins (*not* commands implemented by plugins)
|
|
|
|
``plug [PLUGIN] [PLUGIN] ...``
|
|
|
|
List state and detailed description of the given plugins,
|
|
|
|
including commands implemented by the plugin.
|
2015-09-22 07:30:22 -06:00
|
|
|
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _sc-script:
|
2015-09-24 04:17:58 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
sc-script
|
|
|
|
---------
|
|
|
|
Allows additional scripts to be run when certain events occur
|
|
|
|
(similar to onLoad*.init scripts)
|
2015-09-24 22:15:05 -06:00
|
|
|
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _script:
|
2015-09-24 22:15:05 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
script
|
|
|
|
------
|
|
|
|
Reads a text file, and runs each line as a DFHack command
|
|
|
|
as if it had been typed in by the user - treating the
|
|
|
|
input like `an init file <init-files>`.
|
2015-09-24 22:15:05 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Some other tools, such as `autobutcher` and `workflow`, export
|
|
|
|
their settings as the commands to create them - which are later
|
|
|
|
loaded with ``script``
|
2015-09-24 04:17:58 -06:00
|
|
|
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _show:
|
2015-09-24 04:17:58 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
show
|
|
|
|
----
|
|
|
|
Shows the terminal window after it has been `hidden <hide>`.
|
|
|
|
Only available on Windows. You'll need to use it from a
|
|
|
|
`keybinding` set beforehand, or the in-game `command-prompt`.
|
2015-09-24 04:17:58 -06:00
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
.. _type:
|
2015-09-22 07:30:22 -06:00
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
type
|
|
|
|
----
|
|
|
|
``type command`` shows where ``command`` is implemented.
|
2015-09-24 04:17:58 -06:00
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
Other Commands
|
2015-11-05 06:58:18 -07:00
|
|
|
--------------
|
2015-11-05 17:44:43 -07:00
|
|
|
The following commands are *not* built-in, but offer similarly useful functions.
|
2012-09-20 05:38:58 -06:00
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
* `command-prompt`
|
|
|
|
* `hotkeys`
|
|
|
|
* `lua`
|
|
|
|
* `multicmd`
|
|
|
|
* `nopause`
|
|
|
|
* `quicksave`
|
2015-11-06 22:59:11 -07:00
|
|
|
* `rb`
|
2015-11-05 17:44:43 -07:00
|
|
|
* `repeat`
|
2015-10-23 22:10:15 -06:00
|
|
|
|
2013-09-30 03:19:51 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _init-files:
|
2013-09-30 03:19:51 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Init Files
|
|
|
|
==========
|
2016-08-12 03:04:23 -06:00
|
|
|
|
|
|
|
.. contents::
|
|
|
|
:local:
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
DFHack allows users to automatically run commonly-used DFHack commands
|
|
|
|
when DF is first loaded, when a game is loaded, and when a game is unloaded.
|
2013-09-30 03:19:51 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Init scripts function the same way they would if the user manually typed
|
|
|
|
in their contents, but are much more convenient. In order to facilitate
|
|
|
|
savegave portability, mod merging, and general organization of init files,
|
|
|
|
DFHack supports multiple init files both in the main DF directory and
|
|
|
|
save-specific init files in the save folders.
|
2013-09-30 03:19:51 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
DFHack looks for init files in three places each time they could be run:
|
2012-09-27 01:19:28 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
#. The main DF directory
|
|
|
|
#. :file:`data/save/{world}/raw`, where ``world`` is the current save, and
|
|
|
|
#. :file:`data/save/{world}/raw/objects`
|
2012-09-21 02:19:48 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
When reading commands from dfhack.init or with the `script` command, if the final
|
|
|
|
character on a line is a backslash then the next uncommented line is considered a
|
|
|
|
continuation of that line, with the backslash deleted. Commented lines are skipped,
|
|
|
|
so it is possible to comment out parts of a command with the ``#`` character.
|
2012-09-21 02:19:48 -06:00
|
|
|
|
2015-09-22 07:30:22 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
.. _dfhack.init:
|
2012-09-21 02:19:48 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
dfhack*.init
|
|
|
|
------------
|
|
|
|
If your DF folder contains at least one file named ``dfhack*.init``
|
|
|
|
(where ``*`` is a placeholder for any string), then all such files
|
|
|
|
are executed in alphabetical order when DF is first started.
|
2015-10-18 21:59:35 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
DFHack is distributed with :download:`/dfhack.init-example` as an example
|
|
|
|
with an up-to-date collection of basic commands; mostly setting standard
|
|
|
|
keybindings and `enabling <enable>` plugins. You are encouraged to look
|
|
|
|
through this file to learn which features it makes available under which
|
|
|
|
key combinations. You may also customise it and rename it to ``dfhack.init``.
|
2015-08-13 20:30:45 -06:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
If your DF folder does not contain any ``dfhack*.init`` files, the example
|
|
|
|
will be run as a fallback.
|
|
|
|
|
|
|
|
These files are best used for keybindings and enabling persistent plugins
|
|
|
|
which do not require a world to be loaded.
|
|
|
|
|
|
|
|
|
|
|
|
.. _onLoad.init:
|
|
|
|
|
|
|
|
onLoad*.init
|
|
|
|
------------
|
|
|
|
When a world is loaded, DFHack looks for files of the form ``onLoad*.init``,
|
|
|
|
where ``*`` can be any string, including the empty string.
|
|
|
|
|
2020-07-22 00:23:29 -06:00
|
|
|
All matching init files will be executed in alphabetical order.
|
2015-11-05 06:58:18 -07:00
|
|
|
A world being loaded can mean a fortress, an adventurer, or legends mode.
|
|
|
|
|
|
|
|
These files are best used for non-persistent commands, such as setting
|
2020-07-07 22:12:05 -06:00
|
|
|
a `fix <scripts-fix>` script to run on `repeat`.
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
|
|
|
|
.. _onUnload.init:
|
|
|
|
|
|
|
|
onUnload*.init
|
|
|
|
--------------
|
|
|
|
When a world is unloaded, DFHack looks for files of the form ``onUnload*.init``.
|
|
|
|
Again, these files may be in any of the above three places.
|
|
|
|
All matching init files will be executed in alphebetical order.
|
|
|
|
|
|
|
|
Modders often use such scripts to disable tools which should not affect
|
|
|
|
an unmodded save.
|
|
|
|
|
2016-03-16 06:28:34 -06:00
|
|
|
.. _other_init_files:
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
Other init files
|
|
|
|
----------------
|
2015-11-05 17:44:43 -07:00
|
|
|
|
|
|
|
* ``onMapLoad*.init`` and ``onMapUnload*.init`` are run when a map,
|
|
|
|
distinct from a world, is loaded. This is good for map-affecting
|
2020-07-22 00:23:29 -06:00
|
|
|
commands (e.g. `clean`), or avoiding issues in Legends mode.
|
2015-11-05 17:44:43 -07:00
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
* Any lua script named ``raw/init.d/*.lua``, in the save or main DF
|
|
|
|
directory, will be run when any world or that save is loaded.
|
|
|
|
|
|
|
|
|
2020-07-21 19:39:37 -06:00
|
|
|
.. _env-vars:
|
|
|
|
|
2018-02-11 01:07:25 -07:00
|
|
|
Environment variables
|
|
|
|
=====================
|
|
|
|
|
|
|
|
DFHack's behavior can be adjusted with some environment variables. For example,
|
|
|
|
on UNIX-like systems::
|
|
|
|
|
|
|
|
DFHACK_SOME_VAR=1 ./dfhack
|
|
|
|
|
|
|
|
- ``DFHACK_PORT``: the port to use for the RPC server (used by ``dfhack-run``
|
|
|
|
and `remotefortressreader` among others) instead of the default ``5000``. As
|
|
|
|
with the default, if this port cannot be used, the server is not started.
|
2020-07-21 19:39:37 -06:00
|
|
|
See `remote` for more details.
|
2018-02-11 01:07:25 -07:00
|
|
|
|
|
|
|
- ``DFHACK_DISABLE_CONSOLE``: if set, the DFHack console is not set up. This is
|
|
|
|
the default behavior if ``PRINT_MODE:TEXT`` is set in ``data/init/init.txt``.
|
|
|
|
Intended for situations where DFHack cannot run in a terminal window.
|
|
|
|
|
|
|
|
- ``DFHACK_HEADLESS``: if set, and ``PRINT_MODE:TEXT`` is set, DF's display will
|
|
|
|
be hidden, and the console will be started unless ``DFHACK_DISABLE_CONSOLE``
|
|
|
|
is also set. Intended for non-interactive gameplay only.
|
|
|
|
|
|
|
|
- ``DFHACK_NO_GLOBALS``, ``DFHACK_NO_VTABLES``: ignores all global or vtable
|
|
|
|
addresses in ``symbols.xml``, respectively. Intended for development use -
|
|
|
|
e.g. to make sure tools do not crash when these addresses are missing.
|
|
|
|
|
|
|
|
- ``DFHACK_NO_DEV_PLUGINS``: if set, any plugins from the plugins/devel folder
|
|
|
|
that are built and installed will not be loaded on startup.
|
|
|
|
|
|
|
|
- ``DFHACK_LOG_MEM_RANGES`` (macOS only): if set, logs memory ranges to
|
|
|
|
``stderr.log``. Note that `devel/lsmem` can also do this.
|
|
|
|
|
|
|
|
Other (non-DFHack-specific) variables that affect DFHack:
|
|
|
|
|
|
|
|
- ``TERM``: if this is set to ``dumb`` or ``cons25`` on \*nix, the console will
|
|
|
|
not support any escape sequences (arrow keys, etc.).
|
|
|
|
|
|
|
|
- ``LANG``, ``LC_CTYPE``: if either of these contain "UTF8" or "UTF-8" (not case
|
|
|
|
sensitive), ``DF2CONSOLE()`` will produce UTF-8-encoded text. Note that this
|
|
|
|
should be the case in most UTF-8-capable \*nix terminal emulators already.
|
|
|
|
|
2015-11-05 06:58:18 -07:00
|
|
|
Miscellaneous Notes
|
|
|
|
===================
|
|
|
|
This section is for odd but important notes that don't fit anywhere else.
|
|
|
|
|
2015-11-05 17:44:43 -07:00
|
|
|
* If a DF :kbd:`H` hotkey is named with a DFHack command, pressing
|
2015-11-05 06:58:18 -07:00
|
|
|
the corresponding :kbd:`Fx` button will run that command, instead of
|
|
|
|
zooming to the set location.
|
2016-08-12 03:04:23 -06:00
|
|
|
*This feature will be removed in a future version.* (see :issue:`731`)
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
* The binaries for 0.40.15-r1 to 0.34.11-r4 are on DFFD_.
|
|
|
|
Older versions are available here_.
|
2016-08-12 03:04:23 -06:00
|
|
|
*These files will eventually be migrated to GitHub.* (see :issue:`473`)
|
2015-11-05 06:58:18 -07:00
|
|
|
|
|
|
|
.. _DFFD: http://dffd.bay12games.com/search.php?string=DFHack&id=15&limit=1000
|
|
|
|
.. _here: http://dethware.org/dfhack/download
|