Update shit
This commit is contained in:
parent
a1bb89a4d2
commit
b47a8ad4fa
@ -4,6 +4,8 @@ This is an implementation of a centralized storage network architecture that use
|
||||
|
||||
## Deployment
|
||||
|
||||
First, consider using [someone else's project](https://github.com/lewark/inv.lua) instead of this one. It's liable to be a lot better than mine.
|
||||
|
||||
1. Deploy a Smart Computer
|
||||
2. Connect the computer to at least 1 chest and 1 hopper via physical modem lines. Chests need to be attached from the bottom and hoppers from their output direction
|
||||
3. Put a chest on top of the Smart Computer
|
||||
|
@ -54,9 +54,31 @@ function pushDepositsToChests()
|
||||
end
|
||||
end
|
||||
end
|
||||
function requestItem(name, count)
|
||||
-- Pull a number of an item into the output chest above the machine
|
||||
remaining = count
|
||||
local chests = getConnectedChests()
|
||||
-- For each chest on the network...
|
||||
for k,chest in ipairs(chests) do
|
||||
-- For each slot in that chest...
|
||||
for cslot,citem in pairs(chest.list()) do
|
||||
if
|
||||
citem["name"] == name and
|
||||
citem["count"] > 0
|
||||
then
|
||||
desired = math.max(remaining, citem["count"])
|
||||
output.pullItems(peripheral.getName(chest),cslot,desired)
|
||||
remaining = remaining - desired
|
||||
end
|
||||
if remaining <= 0 then return true end
|
||||
end
|
||||
end
|
||||
if remaining > 0 then return false end
|
||||
end
|
||||
|
||||
-- Application entrypoint
|
||||
function main()
|
||||
requestItem("minecraft:sandstone", 12)
|
||||
while true do
|
||||
-- Manage inventory cleanup tasks
|
||||
pushDepositsToChests() -- Take all deposit terminals and push them into the inventory network
|
||||
|
Loading…
Reference in New Issue
Block a user