Skip to content

Commit e50474e

Browse files
authored
Merge pull request #1452 from myk002/myk_deteriorate
[deteriorate] fix usable parts check
2 parents a79736d + d9722e5 commit e50474e

File tree

1 file changed

+27
-8
lines changed

1 file changed

+27
-8
lines changed

deteriorate.lua

+27-8
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,30 @@ local function is_valid_corpse(item)
113113
return not is_entombed(item)
114114
end
115115

116+
local usable_types = {
117+
'plant',
118+
'silk',
119+
'leather',
120+
'bone',
121+
'shell',
122+
'wood',
123+
'soap',
124+
'tooth',
125+
'horn',
126+
'pearl',
127+
'skull',
128+
'hair_wool',
129+
'yarn',
130+
}
131+
116132
local function is_usable_corpse_piece(item)
117-
return item.corpse_flags.hair_wool or
118-
item.corpse_flags.pearl or
119-
item.corpse_flags.plant or
120-
item.corpse_flags.shell or
121-
item.corpse_flags.silk or
122-
item.corpse_flags.yarn
133+
if item.flags.dead_dwarf or item.corpse_flags.unbutchered then
134+
return false
135+
end
136+
for _,flag in ipairs(usable_types) do
137+
if item.corpse_flags[flag] then return true end
138+
end
139+
return false
123140
end
124141

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

259-
event_loop()
276+
for _,category in ipairs(categories) do
277+
event_loop(category)
278+
end
260279
end
261280

262281
---------------------
@@ -297,7 +316,7 @@ local function status()
297316
local running_str = state.enabled and 'Running' or 'Would run'
298317
print(('deteriorate is %s'):format(state.enabled and 'enabled' or 'disabled'))
299318
print()
300-
for _,category in pairs(categories) do
319+
for _,category in ipairs(categories) do
301320
local status_str = 'Stopped'
302321
local category_data = state.categories[category]
303322
if category_data.enabled then

0 commit comments

Comments
 (0)