diff --git a/changelog.txt b/changelog.txt index 3c21789bbc..0cc9c17f5d 100644 --- a/changelog.txt +++ b/changelog.txt @@ -27,6 +27,7 @@ Template for new versions: # Future ## New Tools +- `undump-buildings`: (reinstated) remove dump designation from in-use building materials ## New Features diff --git a/docs/undump-buildings.rst b/docs/undump-buildings.rst index 8848442734..34fb4ef05f 100644 --- a/docs/undump-buildings.rst +++ b/docs/undump-buildings.rst @@ -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 diff --git a/undump-buildings.lua b/undump-buildings.lua index d8bf60c5aa..50f4e4f96a 100644 --- a/undump-buildings.lua +++ b/undump-buildings.lua @@ -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