Skip to content
Merged
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
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ Template for new versions:
## New Features

## Fixes
- `empty-bin`: renamed ``--liquids`` parameter to ``--force`` and made emptying of containers (bags) with powders contingent on that parameter. Previously powders would just always get disposed.

## Misc Improvements

Expand Down
20 changes: 11 additions & 9 deletions docs/empty-bin.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,20 @@ Examples
--------

``empty-bin``
Empty the contents of selected containers or all containers in the selected stockpile or building, except containers with liquids, onto the floor.
Empty the contents of selected containers or all containers in the selected stockpile or building, except containers with liquids or powders, onto the floor.

``empty-bin --liquids``
Empty the contents of selected containers or all containers in the selected stockpile or building, including containers with liquids, onto the floor.
``empty-bin --force``
Empty the contents of selected containers or all containers in the selected stockpile or building, including containers with liquids or powders, onto the floor.

``empty-bin --recursive --force``
Empty the contents of selected containers or all containers in the selected stockpile or building, including containers with liquids/powders and containers contents that are containers, such as a bags of seeds or filled waterskins, onto the floor.

``empty-bin --recursive --liquids``
Empty the contents of selected containers or all containers in the selected stockpile or building, including containers with liquids and containers contents that are containers, such as a bags of seeds or filled waterskins, onto the floor.

Options
--------------
-------

``-r``, ``--recursive``
Recursively empty containers.
``-l``, ``--liquids``
Move contained liquids (DRINK and LIQUID_MISC) to the floor, making them unusable.
Recursively empty containers.

``-f``, ``--force``
Move contained liquid and powders (DRINK, LIQUID_MISC and POWDER_MISC) to the floor, making them unusable.
11 changes: 6 additions & 5 deletions empty-bin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ local argparse = require('argparse')
local options, args = {
help = false,
recursive = false,
liquids = false
force = false
},
{...}

Expand All @@ -18,9 +18,10 @@ local function emptyContainer(container)
print('Emptying ' .. dfhack.items.getReadableDescription(container))
local pos = xyz2pos(dfhack.items.getPosition(container))
for _, item in ipairs(items) do
local skip_liquid = not options.liquids and (item:getType() == df.item_type.LIQUID_MISC or item:getType() == df.item_type.DRINK)
if skip_liquid then
print(' ' .. dfhack.items.getReadableDescription(item) .. ' was skipped because the --liquids flag was not provided')
local itemType = item:getType()
local skip = not options.force and (itemType == df.item_type.LIQUID_MISC or itemType == df.item_type.DRINK or itemType == df.item_type.POWDER_MISC)
if skip then
print(' ' .. dfhack.items.getReadableDescription(item) .. ' was skipped (use --force to override)')
else
print(' ' .. dfhack.items.getReadableDescription(item))
dfhack.items.moveToGround(item, pos)
Expand All @@ -35,7 +36,7 @@ end
argparse.processArgsGetopt(args,{
{ 'h', 'help', handler = function() options.help = true end },
{ 'r', 'recursive', handler = function() options.recursive = true end },
{ 'l', 'liquids', handler = function() options.liquids = true end }
{ 'f', 'force', handler = function() options.force = true end }
})

if options.help then
Expand Down