Skip to content

Commit 46d4ea8

Browse files
authored
Merge pull request #890 from AndrielChaoti/master
unforbid: ignore tattered items by default
2 parents 87e6f1a + 4b95139 commit 46d4ea8

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

changelog.txt

+1
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ Template for new versions:
3333
## New Features
3434
- `gui/design`: show selected dimensions next to the mouse cursor when designating with vanilla tools, for example when painting a burrow or designating digging
3535
- `quickfort`: new blueprint mode for designating burrows
36+
- `unforbid`: now ignores worn and tattered items by default (X/XX), use -X to bypass
3637

3738
## Fixes
3839
- `gui/unit-syndromes`: show the syndrome names properly in the UI

docs/unforbid.rst

+3
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,6 @@ Options
2424

2525
``-q``, ``--quiet``
2626
Suppress non-error console output.
27+
28+
``-X``, ``--include-worn``
29+
Include worn (X) and tattered (XX) items when unforbidding.

unforbid.lua

+16-7
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
local argparse = require('argparse')
44

5-
local function unforbid_all(include_unreachable, quiet)
6-
if not quiet then print('Unforbidding all items...') end
5+
local function unforbid_all(include_unreachable, quiet, include_worn)
6+
local p
7+
if quiet then p=function(s) return end; else p=function(s) return print(s) end; end
8+
p('Unforbidding all items...')
79

810
local citizens = dfhack.units.getCitizens(true)
911
local count = 0
@@ -19,32 +21,39 @@ local function unforbid_all(include_unreachable, quiet)
1921
end
2022

2123
if not reachable then
22-
if not quiet then print((' unreachable: %s (skipping)'):format(item)) end
24+
p((' unreachable: %s (skipping)'):format(item))
2325
goto skipitem
2426
end
2527
end
2628

27-
if not quiet then print((' unforbid: %s'):format(item)) end
29+
if ((not include_worn) and item.wear >= 2) then
30+
p((' worn: %s (skipping)'):format(item))
31+
goto skipitem
32+
end
33+
34+
p((' unforbid: %s'):format(item))
2835
item.flags.forbid = false
2936
count = count + 1
3037

3138
::skipitem::
3239
end
3340
end
3441

35-
if not quiet then print(('%d items unforbidden'):format(count)) end
42+
p(('%d items unforbidden'):format(count))
3643
end
3744

3845
-- let the common --help parameter work, even though it's undocumented
3946
local options, args = {
4047
help = false,
4148
quiet = false,
4249
include_unreachable = false,
43-
}, { ... }
50+
include_worn = false
51+
}, {...}
4452

4553
local positionals = argparse.processArgsGetopt(args, {
4654
{ 'h', 'help', handler = function() options.help = true end },
4755
{ 'q', 'quiet', handler = function() options.quiet = true end },
56+
{ 'X', 'include-worn', handler = function() options.include_worn = true end},
4857
{ 'u', 'include-unreachable', handler = function() options.include_unreachable = true end },
4958
})
5059

@@ -54,5 +63,5 @@ if positionals[1] == nil or positionals[1] == 'help' or options.help then
5463
end
5564

5665
if positionals[1] == 'all' then
57-
unforbid_all(options.include_unreachable, options.quiet)
66+
unforbid_all(options.include_unreachable, options.quiet, options.include_worn)
5867
end

0 commit comments

Comments
 (0)