Skip to content

Commit 47688de

Browse files
committed
Add z_fix_minecarts script and documentation
1 parent e50474e commit 47688de

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

docs/z_fix_minecarts.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
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`.
2+
3+
## Features
4+
5+
* **Tool Scanning**: Identifies all items of subtype `ITEM_TOOL_MINECART`.
6+
* **Flag Clearing**: Automatically clears the `in_job` flag on minecart tools that are currently marked in a job.
7+
* **Summary Reporting**: Outputs the total count of flags flipped from `true` to `false`.

z_fix_minecarts.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Iterate over all tools, clear the in_job flag for minecarts, and report how many flags were actually flipped from true to false
2+
3+
local tools = df.global.world.items.other.TOOL
4+
local flipped = 0
5+
for i = 0, #tools - 1 do
6+
local tool = tools[i]
7+
-- Only consider minecart tools
8+
if tool.subtype.id == "ITEM_TOOL_MINECART" then
9+
-- Only flip if it was true
10+
if tool.flags.in_job then
11+
tool.flags.in_job = false
12+
flipped = flipped + 1
13+
end
14+
end
15+
end
16+
17+
-- Print count of flags flipped from true to false
18+
dfhack.printerr(string.format(
19+
"clear_minecart_jobs: flipped in_job flag on %d minecart tool(s) from true to false\n", flipped
20+
))

0 commit comments

Comments
 (0)