Skip to content

Commit 63290af

Browse files
authored
Merge pull request #1523 from DoctorVanGogh/master
Change `empty-bin` to not automatically dispose powders.
2 parents 163f2c4 + d066733 commit 63290af

File tree

3 files changed

+18
-14
lines changed

3 files changed

+18
-14
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Template for new versions:
3131
## New Features
3232

3333
## Fixes
34+
- `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.
3435

3536
## Misc Improvements
3637

docs/empty-bin.rst

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,20 @@ Examples
2525
--------
2626

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

30-
``empty-bin --liquids``
31-
Empty the contents of selected containers or all containers in the selected stockpile or building, including containers with liquids, onto the floor.
30+
``empty-bin --force``
31+
Empty the contents of selected containers or all containers in the selected stockpile or building, including containers with liquids or powders, onto the floor.
32+
33+
``empty-bin --recursive --force``
34+
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.
3235

33-
``empty-bin --recursive --liquids``
34-
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.
3536

3637
Options
37-
--------------
38+
-------
3839

3940
``-r``, ``--recursive``
40-
Recursively empty containers.
41-
``-l``, ``--liquids``
42-
Move contained liquids (DRINK and LIQUID_MISC) to the floor, making them unusable.
41+
Recursively empty containers.
42+
43+
``-f``, ``--force``
44+
Move contained liquid and powders (DRINK, LIQUID_MISC and POWDER_MISC) to the floor, making them unusable.

empty-bin.lua

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ local argparse = require('argparse')
88
local options, args = {
99
help = false,
1010
recursive = false,
11-
liquids = false
11+
force = false
1212
},
1313
{...}
1414

@@ -18,9 +18,10 @@ local function emptyContainer(container)
1818
print('Emptying ' .. dfhack.items.getReadableDescription(container))
1919
local pos = xyz2pos(dfhack.items.getPosition(container))
2020
for _, item in ipairs(items) do
21-
local skip_liquid = not options.liquids and (item:getType() == df.item_type.LIQUID_MISC or item:getType() == df.item_type.DRINK)
22-
if skip_liquid then
23-
print(' ' .. dfhack.items.getReadableDescription(item) .. ' was skipped because the --liquids flag was not provided')
21+
local itemType = item:getType()
22+
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)
23+
if skip then
24+
print(' ' .. dfhack.items.getReadableDescription(item) .. ' was skipped (use --force to override)')
2425
else
2526
print(' ' .. dfhack.items.getReadableDescription(item))
2627
dfhack.items.moveToGround(item, pos)
@@ -35,7 +36,7 @@ end
3536
argparse.processArgsGetopt(args,{
3637
{ 'h', 'help', handler = function() options.help = true end },
3738
{ 'r', 'recursive', handler = function() options.recursive = true end },
38-
{ 'l', 'liquids', handler = function() options.liquids = true end }
39+
{ 'f', 'force', handler = function() options.force = true end }
3940
})
4041

4142
if options.help then

0 commit comments

Comments
 (0)