Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 876425f

Browse files
committed
allow multiple filters
1 parent cabdfe6 commit 876425f

5 files changed

Lines changed: 403 additions & 381 deletions

File tree

docs/plugins/stockpiles.rst

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,15 @@ Options
7777
to the stockpile, but no other settings are changed. In ``disable`` mode,
7878
enabled settings in the file are *removed* from the current stockpile
7979
configuration, and nothing else is changed.
80-
``-f``, ``--filter <filter>``
81-
When importing, only modify the settings that contain the given substring.
80+
``-f``, ``--filter <search>[,<search>...]``
81+
When importing, only modify the settings that contain at least one of the
82+
given substrings.
8283

8384
Configuration elements
8485
----------------------
8586

86-
The different configuration elements you can include in an exported settings file
87-
are:
87+
The different configuration elements you can include in an exported settings
88+
file are:
8889

8990
:containers: Max bins, max barrels, and num wheelbarrows.
9091
:general: Whether the stockpile takes from links only and whether organic
@@ -104,9 +105,9 @@ DFHack comes with a library of useful stockpile settings files that are ready
104105
for import. If the stockpile configuration that you need isn't directly
105106
represented, you can often use the ``enable`` and ``disable`` modes and/or
106107
the ``filter`` option to transform an existing saved stockpile setting. Some
107-
stockpile configurations can only be achieved with filters since the contents
108-
of the stockpile lists are different for each world. For example, to disable
109-
all tallow in your main food stockpile, you'd run this command::
108+
stockpile configurations can only be achieved with filters since the stockpile
109+
lists are different for each world. For example, to disable all tallow in your
110+
main food stockpile, you'd run this command::
110111

111112
stockpiles import category_food -m disable -f tallow
112113

@@ -134,18 +135,34 @@ entire category, or with a filter, any matchable subset thereof::
134135
category_weapons
135136
category_wood
136137

137-
For many of the categories, there are also settings files that manipulate interesting
138-
subsets of that category.
138+
For many of the categories, there are also subcategory prefixes that you can
139+
match with filters and convenient pre-made settings files that manipulate
140+
interesting category subsets.
139141

140142
Ammo stockpile adjustments
141143
~~~~~~~~~~~~~~~~~~~~~~~~~~
142144

143-
bolts
144-
metalammo
145-
boneammo
146-
woodammo
147-
masterworkammo
148-
artifactammo
145+
Subcategory prefixes::
146+
147+
type/
148+
mats/
149+
other/
150+
core/
151+
total/
152+
153+
Convenience settings files::
154+
155+
bolts
156+
metalammo
157+
boneammo
158+
woodammo
159+
160+
Example commands for a stockpile of metal bolts::
161+
162+
stockpiles import category_ammo
163+
stockpiles import -m disable -f other/ category_ammo
164+
stockpiles import -m disable -f type/ category_ammo
165+
stockpiles import -m enable bolts
149166

150167
Animal stockpile adjustments
151168
~~~~~~~~~~~~~~~~~~~~~~~~~~~~

plugins/lua/stockpiles.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ local function import_stockpile(name, opts)
113113
else
114114
name = STOCKPILES_LIBRARY_DIR .. '/' .. name
115115
end
116-
stockpiles_import(name, get_sp_id(opts), opts.mode, opts.filter)
116+
stockpiles_import(name, get_sp_id(opts), opts.mode, table.concat(opts.filters, ','))
117117
end
118118

119119
local valid_includes = {general=true, categories=true, types=true}
@@ -145,11 +145,11 @@ local function process_args(opts, args)
145145

146146
opts.includes = {}
147147
opts.mode = 'set'
148-
opts.filter = ''
148+
opts.filters = {}
149149

150150
return argparse.processArgsGetopt(args, {
151151
{'f', 'filter', hasArg=true,
152-
handler=function(arg) opts.filter = arg end},
152+
handler=function(arg) opts.filters = argparse.stringList(arg) end},
153153
{'h', 'help', handler=function() opts.help = true end},
154154
{'i', 'include', hasArg=true,
155155
handler=function(arg) opts.includes = parse_include(arg) end},

0 commit comments

Comments
 (0)