From 47688dea14266dd17d072ca6309eb1f4cf999c69 Mon Sep 17 00:00:00 2001 From: unboundlopez Date: Sun, 15 Jun 2025 21:35:06 -0500 Subject: [PATCH 1/2] Add z_fix_minecarts script and documentation --- docs/z_fix_minecarts.rst | 7 +++++++ z_fix_minecarts.lua | 20 ++++++++++++++++++++ 2 files changed, 27 insertions(+) create mode 100644 docs/z_fix_minecarts.rst create mode 100644 z_fix_minecarts.lua diff --git a/docs/z_fix_minecarts.rst b/docs/z_fix_minecarts.rst new file mode 100644 index 000000000..b7bdacb72 --- /dev/null +++ b/docs/z_fix_minecarts.rst @@ -0,0 +1,7 @@ +This DFHack script iterates over all minecart tool items in the current Dwarf Fortress world, clears their `in_job` flag if it’s set, and reports the total number of flags flipped from `true` to `false`. + +## Features + +* **Tool Scanning**: Identifies all items of subtype `ITEM_TOOL_MINECART`. +* **Flag Clearing**: Automatically clears the `in_job` flag on minecart tools that are currently marked in a job. +* **Summary Reporting**: Outputs the total count of flags flipped from `true` to `false`. diff --git a/z_fix_minecarts.lua b/z_fix_minecarts.lua new file mode 100644 index 000000000..335988ea5 --- /dev/null +++ b/z_fix_minecarts.lua @@ -0,0 +1,20 @@ +-- Iterate over all tools, clear the in_job flag for minecarts, and report how many flags were actually flipped from true to false + +local tools = df.global.world.items.other.TOOL +local flipped = 0 +for i = 0, #tools - 1 do + local tool = tools[i] + -- Only consider minecart tools + if tool.subtype.id == "ITEM_TOOL_MINECART" then + -- Only flip if it was true + if tool.flags.in_job then + tool.flags.in_job = false + flipped = flipped + 1 + end + end +end + +-- Print count of flags flipped from true to false +dfhack.printerr(string.format( + "clear_minecart_jobs: flipped in_job flag on %d minecart tool(s) from true to false\n", flipped +)) \ No newline at end of file From 42be87283da881a5305ed0c479882b7e6476d3d8 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 16 Jun 2025 02:37:01 +0000 Subject: [PATCH 2/2] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- z_fix_minecarts.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/z_fix_minecarts.lua b/z_fix_minecarts.lua index 335988ea5..0f16fc182 100644 --- a/z_fix_minecarts.lua +++ b/z_fix_minecarts.lua @@ -17,4 +17,4 @@ end -- Print count of flags flipped from true to false dfhack.printerr(string.format( "clear_minecart_jobs: flipped in_job flag on %d minecart tool(s) from true to false\n", flipped -)) \ No newline at end of file +))