Skip to content

Add z_fix_minecarts #1466

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/z_fix_minecarts.rst
Original file line number Diff line number Diff line change
@@ -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`.
20 changes: 20 additions & 0 deletions z_fix_minecarts.lua
Original file line number Diff line number Diff line change
@@ -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
))