@@ -170,8 +170,10 @@ if not positionals[1] then
170
170
return
171
171
end
172
172
173
- local count = 0
174
- if positionals [1 ]:lower () == ' undead' then
173
+ local count , target = 0 , ' creature(s)'
174
+ local race_name = table.concat (positionals , ' ' )
175
+ if race_name :lower () == ' undead' then
176
+ target = ' undead'
175
177
if not map_races .UNDEAD then
176
178
qerror (" No undead found on the map." )
177
179
end
@@ -182,23 +184,38 @@ if positionals[1]:lower() == 'undead' then
182
184
end
183
185
end
184
186
else
185
- local selected_race , selected_caste = positionals [ 1 ] , nil
187
+ local selected_race , selected_caste = race_name , nil
186
188
187
189
if string.find (selected_race , ' :' ) then
188
- local tokens = positionals [ 1 ] :split (' :' )
190
+ local tokens = selected_race :split (' :' )
189
191
selected_race , selected_caste = tokens [1 ], tokens [2 ]
190
192
end
191
193
192
194
if not map_races [selected_race ] then
193
- qerror (" No creatures of this race on the map." )
195
+ local selected_race_upper = selected_race :upper ()
196
+ local selected_race_under = selected_race_upper :gsub (' ' , ' _' )
197
+ if map_races [selected_race_upper ] then
198
+ selected_race = selected_race_upper
199
+ elseif map_races [selected_race_under ] then
200
+ selected_race = selected_race_under
201
+ else
202
+ qerror (" No creatures of this race on the map." )
203
+ end
194
204
end
195
205
196
206
local race_castes = getRaceCastes (map_races [selected_race ].id )
197
207
198
208
if selected_caste and not race_castes [selected_caste ] then
199
- qerror (" Invalid caste." )
209
+ local selected_caste_upper = selected_caste :upper ()
210
+ if race_castes [selected_caste_upper ] then
211
+ selected_caste = selected_caste_upper
212
+ else
213
+ qerror (" Invalid caste: " .. selected_caste )
214
+ end
200
215
end
201
216
217
+ target = selected_race
218
+
202
219
for _ , unit in pairs (df .global .world .units .active ) do
203
220
if not checkUnit (unit ) then
204
221
goto skipunit
222
239
end
223
240
end
224
241
225
- print (([[ Exterminated %d creatures .]] ):format (count ))
242
+ print (([[ Exterminated %d %s .]] ):format (count , target ))
0 commit comments