forked from DFHack/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathempty-bin.lua
More file actions
26 lines (20 loc) · 699 Bytes
/
empty-bin.lua
File metadata and controls
26 lines (20 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
-- Empty a bin onto the floor
-- Based on "emptybin" by StoneToad
-- https://gist.github.com/stonetoad/11129025
-- http://dwarffortresswiki.org/index.php/DF2014_Talk:Bin
--[====[
empty-bin
=========
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)))
end
else
print('No contained items')
end