Compare commits
2 Commits
bcbb419179
...
a1bb89a4d2
Author | SHA1 | Date | |
---|---|---|---|
a1bb89a4d2 | |||
53bfc85164 |
@ -6,9 +6,6 @@
|
||||
-- Startup diagnostics
|
||||
print("Salt's CC Storage Net")
|
||||
|
||||
-- Required libraries
|
||||
local basalt = require("basalt") -- wget run https://basalt.madefor.cc/install.lua release latest.lua
|
||||
|
||||
-- Global scope locals
|
||||
local output = peripheral.wrap("top") or error("Put a chest on top of this terminal for output items", 0)
|
||||
|
||||
@ -38,8 +35,21 @@ function pushDepositsToChests()
|
||||
for hslot,hitem in pairs(hopper.list()) do
|
||||
-- For each connected "chest"...
|
||||
for k,chest in ipairs(chests) do
|
||||
-- Attempt to push our items in
|
||||
hopper.pushItems(peripheral.getName(chest),hslot)
|
||||
-- First, make an attempt to find slots that we can shove the item into
|
||||
for cslot,citem in pairs(chest.list()) do
|
||||
if
|
||||
citem["name"] == hitem["name"] and -- We have the same item
|
||||
citem["count"] < chest.getItemLimit(cslot) -- There's space in this slot
|
||||
then
|
||||
hopper.pushItems(peripheral.getName(chest),hslot,hitem["count"],cslot)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- We've fallen through trying to fill up existing stacks. Fragmentation is not a concern, put it wherever
|
||||
if hopper.getItemDetail(hslot) then
|
||||
for k,chest in ipairs(chests) do
|
||||
hopper.pushItems(peripheral.getName(chest),hslot)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user