Skip to content

[deteriorate] fix usable parts check #1452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 27 additions & 8 deletions deteriorate.lua
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,30 @@ local function is_valid_corpse(item)
return not is_entombed(item)
end

local usable_types = {
'plant',
'silk',
'leather',
'bone',
'shell',
'wood',
'soap',
'tooth',
'horn',
'pearl',
'skull',
'hair_wool',
'yarn',
}

local function is_usable_corpse_piece(item)
return item.corpse_flags.hair_wool or
item.corpse_flags.pearl or
item.corpse_flags.plant or
item.corpse_flags.shell or
item.corpse_flags.silk or
item.corpse_flags.yarn
if item.flags.dead_dwarf or item.corpse_flags.unbutchered then
return false
end
for _,flag in ipairs(usable_types) do
if item.corpse_flags[flag] then return true end
end
return false
end

local function is_valid_usable_corpse_piece(item)
Expand Down Expand Up @@ -256,7 +273,9 @@ dfhack.onStateChange[GLOBAL_KEY] = function(sc)
state = get_default_state()
utils.assign(state, dfhack.persistent.getSiteData(GLOBAL_KEY, state))

event_loop()
for _,category in ipairs(categories) do
event_loop(category)
end
end

---------------------
Expand Down Expand Up @@ -297,7 +316,7 @@ local function status()
local running_str = state.enabled and 'Running' or 'Would run'
print(('deteriorate is %s'):format(state.enabled and 'enabled' or 'disabled'))
print()
for _,category in pairs(categories) do
for _,category in ipairs(categories) do
local status_str = 'Stopped'
local category_data = state.categories[category]
if category_data.enabled then
Expand Down