allow depositing items into system
This commit is contained in:
parent
3fe0246d57
commit
fb214842b8
@ -182,6 +182,8 @@ function main_view:move_item(item_name, amount, destination)
|
||||
|
||||
local needed_amount = amount - moved_amount
|
||||
local transferred_amount = peripheral.call(slot_details.peripheral, "pushItems", destination, slot_details.slot, needed_amount)
|
||||
if transferred_amount == 0 then break end
|
||||
|
||||
moved_amount = moved_amount + transferred_amount
|
||||
slot_details.count = slot_details.count - transferred_amount
|
||||
item_collection.count = item_collection.count - transferred_amount
|
||||
@ -264,6 +266,29 @@ function main_view:has_selected_items()
|
||||
return false
|
||||
end
|
||||
|
||||
function main_view:refresh_items()
|
||||
self.item_registry = list_items(self.inventories)
|
||||
populate_item_details(self.item_details, self.item_registry)
|
||||
|
||||
self.left_store.all_items = get_item_counts(self.item_registry)
|
||||
self.right_store.all_items = {}
|
||||
self:refresh_filtered_names(self.left_store, self.left_area)
|
||||
self:refresh_filtered_names(self.right_store, self.right_area)
|
||||
end
|
||||
|
||||
function main_view:deposit_items()
|
||||
for slot, item in pairs(peripheral.call(self.result_inventory, "list")) do
|
||||
local total_transferred = 0
|
||||
for _, inventory in ipairs(self.inventories) do
|
||||
local transferred = peripheral.call(self.result_inventory, "pushItems", inventory, slot)
|
||||
total_transferred = total_transferred + transferred
|
||||
|
||||
if total_transferred == item.count then break end
|
||||
end
|
||||
end
|
||||
self:refresh_items()
|
||||
end
|
||||
|
||||
function main_view:draw()
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.clear()
|
||||
@ -304,13 +329,7 @@ function main_view:on_key(key)
|
||||
elseif key == keys.tab then
|
||||
self.is_left_active = not self.is_left_active
|
||||
elseif key == keys.f5 then
|
||||
self.item_registry = list_items(self.inventories)
|
||||
populate_item_details(self.item_details, self.item_registry)
|
||||
|
||||
self.left_store.all_items = get_item_counts(self.item_registry)
|
||||
self.right_store.all_items = {}
|
||||
self:refresh_filtered_names(self.left_store, self.left_area)
|
||||
self:refresh_filtered_names(self.right_store, self.right_area)
|
||||
self:refresh_items()
|
||||
end
|
||||
|
||||
if self.ctrl_down then
|
||||
@ -335,6 +354,7 @@ function main_view:on_key(key)
|
||||
end
|
||||
end
|
||||
elseif key == keys.d then
|
||||
self:deposit_items()
|
||||
end
|
||||
|
||||
if self.is_left_active then
|
||||
|
Loading…
Reference in New Issue
Block a user