-
-
Save eswald/5553920 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local events_by_type={} | |
local event_types={} | |
for k,v in pairs(df.global.world.units.active) do | |
if dfhack.units.isCitizen(v) then | |
local mytypes={} | |
for idx,event in pairs(v.status.recent_events) do | |
local t=event.type | |
if mytypes[t]==nil then | |
if events_by_type[t] then | |
events_by_type[t]=events_by_type[t]+1 | |
else | |
events_by_type[t]=1 | |
table.insert(event_types,t) | |
end | |
mytypes[t]=true | |
end | |
end | |
end | |
end | |
local function thought_cmp(a, b) | |
return events_by_type[a] < events_by_type[b] | |
end | |
table.sort(event_types,thought_cmp) | |
for k,v in ipairs(event_types) do | |
print(events_by_type[v],df.unit_thought_type.attrs[v].caption) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Prints good and bad thoughts experienced by your dwarves, in ascending order by number of occurrences.
(Perhaps age and severity should be taken into account, but that's trickier.)