Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Template for new versions:
## Fixes

## Misc Improvements
- `combine`: try harder to find the currently-selected stockpile

## Removed

Expand Down
20 changes: 20 additions & 0 deletions combine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -736,6 +736,26 @@ local function get_stockpile_here()
-- return the stockpile as a table
local stockpiles = {}
local building = dfhack.gui.getSelectedStockpile(true)

-- try finding the stockpile by viewed item or first item in itemlist viewsheet.
if building == nil then
local item = nil
if dfhack.gui.getSelectedItem(true) ~= nil then
item = dfhack.gui.getSelectedItem(true)
elseif tonumber(dfhack.DF_VERSION:match("^0*%.*(%d+%.%d+)")) >= 50.07 -- matchFocusString() in Commit a770a4c
and dfhack.gui.matchFocusString("dwarfmode/ViewSheets/ITEM_LIST", dfhack.gui.getDFViewscreen())
and df.global.game.main_interface.view_sheets.open == true
and df.global.game.main_interface.view_sheets.active_sheet == df.view_sheet_type.ITEM_LIST
and #df.global.game.main_interface.view_sheets.viewing_itid > 0
then
local itemid = df.global.game.main_interface.view_sheets.viewing_itid[0]
item = df.item.find(itemid)
end
local pos = (item) and xyz2pos(dfhack.items.getPosition(item)) or nil
building = (pos) and dfhack.buildings.findAtTile(pos) or nil
building = (df.building_stockpilest:is_instance(building)) and building or nil
end

if not building then qerror('Please select a stockpile.') end
table.insert(stockpiles, building)
if opts.verbose > 0 then
Expand Down
4 changes: 3 additions & 1 deletion docs/combine.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ Commands
``all``
Search all stockpiles.
``here``
Search the currently selected stockpile.
Search the currently selected stockpile, or the stockpile that the
currently-seelected item is in, or the stockpile that the currently-
displayed item-list is in.

Options
-------
Expand Down