Skip to content

Commit

Permalink
reinstate undump-buildings
Browse files Browse the repository at this point in the history
  • Loading branch information
myk002 committed Feb 9, 2024
1 parent e13d79b commit 38edc87
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 25 deletions.
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Template for new versions:
# Future

## New Tools
- `undump-buildings`: (reinstated) remove dump designation from in-use building materials

## New Features

Expand Down
2 changes: 1 addition & 1 deletion docs/undump-buildings.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ undump-buildings

.. dfhack-tool::
:summary: Undesignate building base materials for dumping.
:tags: unavailable
:tags: fort productivity buildings

If you designate a bunch of tiles in dump mode, all the items on those tiles
will be marked for dumping. Unfortunately, if there are buildings on any of
Expand Down
33 changes: 9 additions & 24 deletions undump-buildings.lua
Original file line number Diff line number Diff line change
@@ -1,35 +1,20 @@
-- Undesignates building base materials for dumping.
--[====[
undump-buildings
================
Undesignates building base materials for dumping.
]====]

function undump_buildings()
local buildings = df.global.world.buildings.all
local undumped = 0
for i = 0, #buildings - 1 do
local building = buildings[i]
for _, building in ipairs(df.global.world.buildings.all) do
-- Zones and stockpiles don't have the contained_items field.
if df.building_actual:is_instance(building) then
local items = building.contained_items --hint:df.building_actual
for j = 0, #items - 1 do
local contained = items[j]
if contained.use_mode == 2 and contained.item.flags.dump then
-- print(building, contained.item)
undumped = undumped + 1
contained.item.flags.dump = false
end
if not df.building_actual:is_instance(building) then goto continue end
for _, contained in ipairs(building.contained_items) do
if contained.use_mode == 2 and contained.item.flags.dump then
undumped = undumped + 1
contained.item.flags.dump = false
end
end
::continue::
end

if undumped > 0 then
local s = "s"
if undumped == 1 then s = "" end
print("Undumped "..undumped.." item"..s..".")
local s = undumped == 1 and '' or 's'
print(('Undumped %s in-use building item%s'):format(undumped, s))
end
end

Expand Down

0 comments on commit 38edc87

Please sign in to comment.