@@ -137,6 +137,24 @@ local function order_instrument(name, amount, quiet)
137137 end
138138end
139139
140+ local function order_instruments (filter_fn , amount , quiet )
141+ local matched = {}
142+
143+ for _ , instr in ipairs (raws .itemdefs .instruments ) do
144+ if instr .source_enid == civ_id and filter_fn (instr ) then
145+ table.insert (matched , instr )
146+ end
147+ end
148+
149+ if # matched == 0 then
150+ qerror (" No instruments matched the selection" )
151+ end
152+
153+ for _ , instr in ipairs (matched ) do
154+ order_instrument (dfhack .toSearchNormalized (instr .name ), amount , quiet )
155+ end
156+ end
157+
140158local help = false
141159local quiet = false
142160local positionals = argparse .processArgsGetopt ({... }, {
@@ -159,4 +177,14 @@ elseif positionals[1] == "order" then
159177
160178 local amount = positionals [3 ] or 1
161179 order_instrument (instrument_name , amount , quiet )
180+ elseif positionals [1 ] == " all" then
181+ local amount = positionals [2 ] or 1
182+ order_instruments (function () return true end , amount , quiet )
183+ elseif positionals [1 ] == " handheld" then
184+ local amount = positionals [2 ] or 1
185+ order_instruments (function (instr ) return not instr .flags .PLACED_AS_BUILDING end , amount , quiet )
186+ elseif positionals [1 ] == " building" then
187+ local amount = positionals [2 ] or 1
188+ order_instruments (function (instr ) return instr .flags .PLACED_AS_BUILDING end , amount , quiet )
162189end
190+ `
0 commit comments