Skip to content
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

Expand empty-bin to allow you to empty currently selected stockpile #1173

Merged
merged 12 commits into from
Jun 25, 2024
29 changes: 20 additions & 9 deletions empty-bin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,26 @@ Empties the contents of the selected bin onto the floor.

]====]

local bin = dfhack.gui.getSelectedItem(true) or qerror("No item selected")
local items = dfhack.items.getContainedItems(bin)

if #items > 0 then
print('Emptying ' .. dfhack.items.getDescription(bin, 0))
for _, item in pairs(items) do
print(' ' .. dfhack.items.getDescription(item, 0))
dfhack.items.moveToGround(item, xyz2pos(dfhack.items.getPosition(bin)))
local function emptyContainer(container)
local items = dfhack.items.getContainedItems(container)

if #items > 0 then
print('Emptying ' .. dfhack.items.getDescription(container, 0))
Crystalwarrior marked this conversation as resolved.
Show resolved Hide resolved
for _, item in pairs(items) do
print(' ' .. dfhack.items.getDescription(item, 0))
dfhack.items.moveToGround(item, xyz2pos(dfhack.items.getPosition(container)))
end
end
end


local stockpile = dfhack.gui.getSelectedStockpile(true)
if stockpile then
local contents = dfhack.buildings.getStockpileContents(stockpile)
for _, container in ipairs(contents) do
emptyContainer(container)
end
else
print('No contained items')
local bin = dfhack.gui.getSelectedItem(true) or qerror("No item selected")
emptyContainer(bin)
end