From b74b106f1933c435bcaf1518893c09e25c4b4896 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 5 Jan 2025 18:47:10 -0800 Subject: [PATCH 1/2] fix mysterious new errors in CI --- docs/dev/Lua API.rst | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 64bea03c3a..c06f422927 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -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 ----------- @@ -3730,10 +3729,10 @@ paths will be relative to the top level game directory and will end in a slash Retrieve the directory path where a mod with the given ID should store its persistent state. Example:: - local json = require('json') - local scriptmanager = require('script-manager') - local path = scriptmanager.getModStatePath('my_awesome_mod') - config = config or json.open(path .. 'settings.json') + local json = require("json") + local scriptmanager = require("script-manager") + local path = scriptmanager.getModStatePath("my_awesome_mod") + config = config or json.open(path .. "settings.json") Which would open ``dfhack-config/mods/my_awesome_mod/settings.json``. After calling ``getModStatePath``, the returned directory is guaranteed to exist. From 4ef86444f705c1c04169769ab38a370f3bf6f8c0 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 5 Jan 2025 18:51:40 -0800 Subject: [PATCH 2/2] try changing highlight style --- docs/dev/Lua API.rst | 12 ++++++++---- docs/guides/modding-guide.rst | 4 ++++ 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index c06f422927..6f1fff5de2 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -3702,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 @@ -3729,10 +3731,10 @@ paths will be relative to the top level game directory and will end in a slash Retrieve the directory path where a mod with the given ID should store its persistent state. Example:: - local json = require("json") - local scriptmanager = require("script-manager") - local path = scriptmanager.getModStatePath("my_awesome_mod") - config = config or json.open(path .. "settings.json") + local json = require('json') + local scriptmanager = require('script-manager') + local path = scriptmanager.getModStatePath('my_awesome_mod') + config = config or json.open(path .. 'settings.json') Which would open ``dfhack-config/mods/my_awesome_mod/settings.json``. After calling ``getModStatePath``, the returned directory is guaranteed to exist. @@ -3740,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 ab, *0* otherwise. diff --git a/docs/guides/modding-guide.rst b/docs/guides/modding-guide.rst index e93051d41a..5906c75208 100644 --- a/docs/guides/modding-guide.rst +++ b/docs/guides/modding-guide.rst @@ -238,6 +238,8 @@ immensely, and you can always ask for help in the `right places `. 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: @@ -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