Skip to content

Commit

Permalink
Merge branch 'develop' into adv-beta
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Jan 6, 2025
2 parents d0ff179 + 5d28ceb commit 649d527
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 11 additions & 8 deletions docs/dev/Lua API.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3155,15 +3155,14 @@ unless otherwise noted.

* ``dfhack.filesystem.listdir_recursive(path [, depth = 10[, include_prefix = true]])``

Lists all files/directories in a directory and its subdirectories. All directories
are listed before their contents. Returns a table with subtables of the format::
Lists all files/directories in a directory and its subdirectories. All
directories are listed before their contents. Returns a table with subtables
of the format: ``{path: 'path to file', isdir: true|false}``

{path: 'path to file', isdir: true|false}

Note that ``listdir()`` returns only the base name of each directory entry, while
``listdir_recursive()`` returns the initial path and all components following it
for each entry. Set ``include_prefix`` to false if you don't want the ``path``
string prepended to the returned filenames.
Note that ``listdir()`` returns only the base name of each directory entry,
while ``listdir_recursive()`` returns the initial path and all components
following it for each entry. Set ``include_prefix`` to false if you don't
want the ``path`` string prepended to the returned filenames.

Console API
-----------
Expand Down Expand Up @@ -3703,6 +3702,8 @@ functions. These are invoked just like standard string functions, e.g.::
script-manager
==============

.. highlight:: none

This module contains functions useful for mods that contain DFHack scripts to
retrieve source and state paths. The value to pass as ``mod_id`` must be the
same as the mod ID in the mod's :file:`info.txt` metadata file. The returned
Expand Down Expand Up @@ -3741,6 +3742,8 @@ paths will be relative to the top level game directory and will end in a slash
utils
=====

.. highlight:: lua

* ``utils.compare(a,b)``

Comparator function; returns *-1* if a<b, *1* if a>b, *0* otherwise.
Expand Down
4 changes: 4 additions & 0 deletions docs/guides/modding-guide.rst
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,8 @@ immensely, and you can always ask for help in the `right places <support>`.
Reading and writing files and other persistent state
----------------------------------------------------

.. highlight:: none

There are several locations and APIs that a mod might need to read or store
data:

Expand All @@ -254,6 +256,8 @@ for reading and writing JSON data. For example::
-- modify state in the config.data table and persist it when it changes with
-- config:write()

.. highlight:: lua

State that should be saved with a world or a specific fort within that world
should use `persistent-api` API. You can attach a state change hook for new
world loaded where you can load the state, which often includes whether the mod
Expand Down
2 changes: 1 addition & 1 deletion scripts

0 comments on commit 649d527

Please sign in to comment.