From b0729c78e8ca6bf6170dd42343eb5fe801d8cb60 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sun, 12 Nov 2023 20:58:06 +0100 Subject: [PATCH 1/5] Add world module documentation --- docs/dev/Lua API.rst | 48 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index e63bc8a61..7c089ea7c 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -1783,6 +1783,54 @@ Items module Checks whether the item is assigned to a squad. +.. _lua-world: + +World module +------------ + +* ``dfhack.world.ReadPauseState()`` + + Returns *true* if the game is paused. + +* ``dfhack.world.SetPauseState(paused)`` + + Sets the pause state of the game. + +* ``dfhack.world.ReadCurrentYear()`` + + Returns the current game year. + +* ``dfhack.world.ReadCurrentTick()`` + + Returns the current game tick. + +* ``dfhack.world.ReadCurrentMonth()`` + + Returns the current game month. + +* ``dfhack.world.ReadCurrentDay()`` + + Returns the current game day. + +* ``dfhack.world.ReadCurrentWeather()`` + + Returns the current game weather (`df.weather_type`). + +* ``dfhack.world.SetCurrentWeather(weather)`` + + Sets the current game weather to `weather`. + +* ``dfhack.world.ReadWorldFolder()`` + + Returns the name of the directory/folder the current saved game is under, or an empty string if no game was loaded this session. + +* ``dfhack.world.isFortressMode([gametype])`` +* ``dfhack.world.isAdventureMode([gametype])`` +* ``dfhack.world.isArena([gametype])`` +* ``dfhack.world.isLegends([gametype])`` + + Without any arguments, returns *true* if the current gametype matches. Optionally accepts a gametype id to match against. + .. _lua-maps: Maps module From e70adf169210c755874ee3f3ccccb230b98f8174 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Sun, 12 Nov 2023 21:16:28 +0100 Subject: [PATCH 2/5] Fix undefined labels --- docs/dev/Lua API.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 7c089ea7c..9ccd0c007 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -1814,11 +1814,11 @@ World module * ``dfhack.world.ReadCurrentWeather()`` - Returns the current game weather (`df.weather_type`). + Returns the current game weather (``df.weather_type``). * ``dfhack.world.SetCurrentWeather(weather)`` - Sets the current game weather to `weather`. + Sets the current game weather to ``weather``. * ``dfhack.world.ReadWorldFolder()`` From e4c31445089a4948631827bd9dc8fa57344bfdeb Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:16:50 +0100 Subject: [PATCH 3/5] Include range information for month/day docs --- docs/dev/Lua API.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/dev/Lua API.rst b/docs/dev/Lua API.rst index 9ccd0c007..b6e20e3fd 100644 --- a/docs/dev/Lua API.rst +++ b/docs/dev/Lua API.rst @@ -1802,15 +1802,15 @@ World module * ``dfhack.world.ReadCurrentTick()`` - Returns the current game tick. + Returns the number of game ticks (``df.global.world.frame_counter``) since the start of the current game year. * ``dfhack.world.ReadCurrentMonth()`` - Returns the current game month. + Returns the current game month, ranging from 0-11 (The Dwarven year has 12 months). * ``dfhack.world.ReadCurrentDay()`` - Returns the current game day. + Returns the current game day, ranging from 1-28 (Each Dwarven month as 28 days) * ``dfhack.world.ReadCurrentWeather()`` From fcb69a1e7a5ceb690753d63bd24dfb09b0f14d96 Mon Sep 17 00:00:00 2001 From: vallode <18506096+vallode@users.noreply.github.com> Date: Mon, 13 Nov 2023 08:46:36 +0100 Subject: [PATCH 4/5] Add to changelog --- docs/changelog.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/changelog.txt b/docs/changelog.txt index 7d4bd69ed..8881bd58d 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -91,6 +91,7 @@ Template for new versions: - ``dfhack.gui.getMousePos``: support new optional ``allow_out_of_bounds`` parameter - ``gui.FRAME_THIN``: a panel frame suitable for floating tooltips - ``dfhack.buildings.completebuild``: expose new module API +- ``dfhack.world``: add documentation for world module ## Removed From 54dd4c2bf5ffb402ac3755fed49ebe16703222c6 Mon Sep 17 00:00:00 2001 From: Myk Date: Mon, 13 Nov 2023 18:59:14 -0800 Subject: [PATCH 5/5] Update changelog.txt --- docs/changelog.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 8881bd58d..427f01f9f 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -76,6 +76,7 @@ Template for new versions: - `dreamfort`: Inside+ and Clearcutting burrows now automatically created and managed ## Documentation +- Document the Lua API for the ``dfhack.world`` module ## API - ``Gui::revealInDwarfmodeMap``: gained ``highlight`` parameter to control setting the tile highlight on the zoom target @@ -91,7 +92,6 @@ Template for new versions: - ``dfhack.gui.getMousePos``: support new optional ``allow_out_of_bounds`` parameter - ``gui.FRAME_THIN``: a panel frame suitable for floating tooltips - ``dfhack.buildings.completebuild``: expose new module API -- ``dfhack.world``: add documentation for world module ## Removed