Created
April 21, 2014 00:33
Some helper scripts for dfhack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Empty a bin onto the floor | |
print('Finding selected item...') | |
a = dfhack.gui.getSelectedItem() | |
print('Found ', dfhack.items.getDescription(a,0)) | |
if not a then dfhack.printerr("No item selected!") | |
end | |
loc = a.pos | |
-- dfhack.items.moveToGround(a,loc) | |
for _,k in pairs(dfhack.items.getContainedItems(a)) do | |
print (' ', dfhack.items.getDescription(k,0)) | |
r = dfhack.items.moveToGround(k,loc) | |
end | |
print('Done.') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Split the selected stack into single items | |
-- Only tested with coins... | |
print('Finding selected item...') | |
a = dfhack.gui.getSelectedItem() | |
print('Found ', dfhack.items.getDescription(a,0)) | |
if not a then dfhack.printerr("No item selected!") | |
end | |
loc = a.pos | |
dfhack.items.moveToGround(a,loc) | |
split_size = 1 -- split the stack into split_size stacks | |
while a.stack_size > split_size do | |
n = a:new() | |
n.stack_size = split_size | |
a.stack_size = a.stack_size - n.stack_size | |
n.id = df.global.item_next_id | |
df.global.item_next_id = df.global.item_next_id + 1 | |
-- n.categorize(true) -- bugged, need it for stuff to show up in stocks | |
df.global.world.items.all:insert('#',n) | |
n.flags.on_ground = false | |
n.flags.removed = true -- it's not actually anywhere | |
n.flags.garbage_collect = true -- hack to get categorize called for us... | |
dfhack.items.moveToGround(n, loc) | |
end | |
print('Done.') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment