Fix centrifuge distribution code

This commit is contained in:
Anton Reinhard 2024-05-19 19:55:18 +02:00
parent b9dc5a5d35
commit c277dc9623
2 changed files with 49 additions and 27 deletions

View File

@ -201,9 +201,14 @@ function moveTo(x, y)
end
function resupplyItem(slot, num)
module = peripheral.wrap("right")
turtle.select(slot)
while (turtle.getItemCount(slot) < num) do
turtle.suck(num - turtle.getItemCount(slot))
items = turtle.getItemCount(slot)
while (items < num) do
module.suckSneaky(1, num - items)
sleep(1)
items = turtle.getItemCount(slot)
end
end
@ -246,6 +251,7 @@ function supplyCentrifuge()
module = peripheral.wrap("right")
-- drop cells from below (side 0)
if (cells_drop > 0) then
turtle.select(slot_cells_cur)
drop = cells_drop
if (turtle.getItemCount(slot_cells_cur) < drop) then
@ -255,6 +261,7 @@ function supplyCentrifuge()
turtle.select(slot_cells_cur)
end
module.dropSneakyUp(0, drop)
end
-- drop input from above (side 1)
turtle.select(slot_input_cur)
@ -357,16 +364,19 @@ function setupSlots(cells, input, output_1, output_2, output_3, output_4)
end
function enterSupplyLoop()
module = peripheral.wrap("right")
while true do
print("Resupplying...")
resupplyAll()
-- go to first centrifuge and wait to start
-- go to first centrifuge and wait to start (by checking ingredient)
moveTo(1, 0)
turtle.select(16)
while turtle.suckUp() do
while module.suckSneakyUp(1, input_drop) do
putBack = turtle.getItemCount(16)
turtle.dropUp(putBack)
sleep(1)
module.dropSneakyUp(1, putBack)
sleep(5)
end
@ -411,4 +421,5 @@ function platinumLoop()
end
print("Centrifuges even item distribution program")
platinumLoop()
redstoneLoop()

View File

@ -201,9 +201,14 @@ function moveTo(x, y)
end
function resupplyItem(slot, num)
module = peripheral.wrap("right")
turtle.select(slot)
while (turtle.getItemCount(slot) < num) do
turtle.suck(num - turtle.getItemCount(slot))
items = turtle.getItemCount(slot)
while (items < num) do
module.suckSneaky(1, num - items)
sleep(1)
items = turtle.getItemCount(slot)
end
end
@ -246,6 +251,7 @@ function supplyCentrifuge()
module = peripheral.wrap("right")
-- drop cells from below (side 0)
if (cells_drop > 0) then
turtle.select(slot_cells_cur)
drop = cells_drop
if (turtle.getItemCount(slot_cells_cur) < drop) then
@ -255,6 +261,7 @@ function supplyCentrifuge()
turtle.select(slot_cells_cur)
end
module.dropSneakyUp(0, drop)
end
-- drop input from above (side 1)
turtle.select(slot_input_cur)
@ -357,16 +364,19 @@ function setupSlots(cells, input, output_1, output_2, output_3, output_4)
end
function enterSupplyLoop()
module = peripheral.wrap("right")
while true do
print("Resupplying...")
resupplyAll()
-- go to first centrifuge and wait to start
-- go to first centrifuge and wait to start (by checking ingredient)
moveTo(1, 0)
turtle.select(16)
while turtle.suckUp() do
while module.suckSneakyUp(1, input_drop) do
putBack = turtle.getItemCount(16)
turtle.dropUp(putBack)
sleep(1)
module.dropSneakyUp(1, putBack)
sleep(5)
end
@ -411,4 +421,5 @@ function redstoneLoop()
end
print("Centrifuges even item distribution program")
redstoneLoop()