diff --git a/changelog.txt b/changelog.txt index d84f46e54..7b84ea034 100644 --- a/changelog.txt +++ b/changelog.txt @@ -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 diff --git a/docs/empty-bin.rst b/docs/empty-bin.rst index 1d45eb81a..e6e8bf408 100644 --- a/docs/empty-bin.rst +++ b/docs/empty-bin.rst @@ -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. diff --git a/empty-bin.lua b/empty-bin.lua index 8e38c13d8..0f2a183db 100644 --- a/empty-bin.lua +++ b/empty-bin.lua @@ -8,7 +8,7 @@ local argparse = require('argparse') local options, args = { help = false, recursive = false, - liquids = false + force = false }, {...} @@ -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) @@ -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