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