diff --git a/changelog.txt b/changelog.txt index 50bfd543b..30ace4473 100644 --- a/changelog.txt +++ b/changelog.txt @@ -58,6 +58,7 @@ Template for new versions: - `assign-minecarts`: reassign vehicles to routes where the vehicle has been destroyed (or has otherwise gone missing) - `fix/dry-buckets`: prompt DF to recheck requests for aid (e.g. "bring water" jobs) when a bucket is unclogged and becomes available for use - `idle-crafting`: make choice of crafting job dependent on resources in linked stockpiles. +- `exterminate`: show descriptive names for the listed races in addition to their IDs ## Documentation - `gui/embark-anywhere`: add information about how the game determines world tile pathability and instructions for bridging two landmasses diff --git a/exterminate.lua b/exterminate.lua index 06b764eb9..0043febb9 100644 --- a/exterminate.lua +++ b/exterminate.lua @@ -134,10 +134,12 @@ local function getMapRaces(opts) local map_races = {} for _, unit in pairs(df.global.world.units.active) do if not checkUnit(opts, unit) then goto continue end - local unit_race_name = dfhack.units.isUndead(unit) and "UNDEAD" or df.creature_raw.find(unit.race).creature_id + local craw = df.creature_raw.find(unit.race) + local unit_race_name = dfhack.units.isUndead(unit) and 'UNDEAD' or craw.creature_id local race = ensure_key(map_races, unit_race_name) race.id = unit.race race.name = unit_race_name + race.display_name = unit_race_name == 'UNDEAD' and '' or craw.name[0] race.count = (race.count or 0) + 1 ::continue:: end @@ -187,14 +189,20 @@ local map_races = getMapRaces(options) if not positionals[1] or positionals[1] == 'list' then local sorted_races = {} - for race, value in pairs(map_races) do - table.insert(sorted_races, { name = race, count = value.count }) + local max_width = 10 + for _,v in pairs(map_races) do + max_width = math.max(max_width, #v.name) + table.insert(sorted_races, v) end table.sort(sorted_races, function(a, b) return a.count > b.count end) - for _, race in ipairs(sorted_races) do - print(([[%4s %s]]):format(race.count, race.name)) + for _,v in ipairs(sorted_races) do + local name_str = v.name + if name_str ~= 'UNDEAD' and v.display_name ~= string.lower(name_str):gsub('_', ' ') then + name_str = ('%-'..tostring(max_width)..'s (%s)'):format(name_str, v.display_name) + end + print(('%4s %s'):format(v.count, name_str)) end return end