diff --git a/changelog.txt b/changelog.txt index f7e41acd3b..6b64a26fc9 100644 --- a/changelog.txt +++ b/changelog.txt @@ -33,6 +33,7 @@ Template for new versions: ## New Features - `gui/design`: show selected dimensions next to the mouse cursor when designating with vanilla tools, for example when painting a burrow or designating digging - `quickfort`: new blueprint mode for designating burrows +- `unforbid`: now ignores worn and tattered items by default (X/XX), use -X to bypass ## Fixes - `gui/unit-syndromes`: show the syndrome names properly in the UI diff --git a/docs/unforbid.rst b/docs/unforbid.rst index 4160b7b25e..03615492ad 100644 --- a/docs/unforbid.rst +++ b/docs/unforbid.rst @@ -24,3 +24,6 @@ Options ``-q``, ``--quiet`` Suppress non-error console output. + +``-X``, ``--include-worn`` + Include worn (X) and tattered (XX) items when unforbidding. diff --git a/unforbid.lua b/unforbid.lua index 38667602c1..12b7430c36 100644 --- a/unforbid.lua +++ b/unforbid.lua @@ -2,8 +2,10 @@ local argparse = require('argparse') -local function unforbid_all(include_unreachable, quiet) - if not quiet then print('Unforbidding all items...') end +local function unforbid_all(include_unreachable, quiet, include_worn) + local p + if quiet then p=function(s) return end; else p=function(s) return print(s) end; end + p('Unforbidding all items...') local citizens = dfhack.units.getCitizens(true) local count = 0 @@ -19,12 +21,17 @@ local function unforbid_all(include_unreachable, quiet) end if not reachable then - if not quiet then print((' unreachable: %s (skipping)'):format(item)) end + p((' unreachable: %s (skipping)'):format(item)) goto skipitem end end - if not quiet then print((' unforbid: %s'):format(item)) end + if ((not include_worn) and item.wear >= 2) then + p((' worn: %s (skipping)'):format(item)) + goto skipitem + end + + p((' unforbid: %s'):format(item)) item.flags.forbid = false count = count + 1 @@ -32,7 +39,7 @@ local function unforbid_all(include_unreachable, quiet) end end - if not quiet then print(('%d items unforbidden'):format(count)) end + p(('%d items unforbidden'):format(count)) end -- let the common --help parameter work, even though it's undocumented @@ -40,11 +47,13 @@ local options, args = { help = false, quiet = false, include_unreachable = false, -}, { ... } + include_worn = false +}, {...} local positionals = argparse.processArgsGetopt(args, { { 'h', 'help', handler = function() options.help = true end }, { 'q', 'quiet', handler = function() options.quiet = true end }, + { 'X', 'include-worn', handler = function() options.include_worn = true end}, { 'u', 'include-unreachable', handler = function() options.include_unreachable = true end }, }) @@ -54,5 +63,5 @@ if positionals[1] == nil or positionals[1] == 'help' or options.help then end if positionals[1] == 'all' then - unforbid_all(options.include_unreachable, options.quiet) + unforbid_all(options.include_unreachable, options.quiet, options.include_worn) end