@@ -32,12 +32,25 @@ local function isValidItem(item)
3232 return true
3333end
3434
35- local function GetStockpileItems (stockpile )
36- local stockPileItems = dfhack .buildings .getStockpileContents (stockpile )
35+ local function GetstockpileItems (stockpile )
36+ local stockpileItems = dfhack .buildings .getStockpileContents (stockpile )
3737 local items = {}
38- for _ , stockPileItem in ipairs (stockPileItems ) do
39- if # stockPileItems > 0 and isValidItem (stockPileItem ) then
40- table.insert (items , stockPileItem )
38+ for _ , stockpileItem in ipairs (stockpileItems ) do
39+ local containedItems = {}
40+ for _ , generalRef in ipairs (stockpileItem .general_refs ) do
41+ if df .general_ref_contains_itemst :is_instance (generalRef ) then
42+ containedItems = dfhack .items .getContainedItems (stockpileItem )
43+ end
44+ end
45+ if # containedItems > 0 then
46+ for _ , containedItem in ipairs (containedItems ) do
47+ if isValidItem (containedItem ) then
48+ table.insert (items , containedItem )
49+ end
50+ end
51+ end
52+ if # stockpileItems > 0 and isValidItem (stockpileItem ) then
53+ table.insert (items , stockpileItem )
4154 end
4255 end
4356 return items
@@ -108,7 +121,7 @@ local function Main(args)
108121 elseif dfhack .world .isFortressMode () then
109122 local stockpile = dfhack .gui .getSelectedStockpile (true )
110123 if stockpile and df .building_stockpilest :is_instance (stockpile ) then
111- items = GetStockpileItems (stockpile )
124+ items = GetstockpileItems (stockpile )
112125 if # items < 1 then qerror (' Selected stockpile contains no items that can be resized.' ) end
113126 end
114127 end
0 commit comments