asweigart

brickcrafter

Jul 29th, 2016
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. --[[Stone Brick Factory program by Al Sweigart
  2. Gets stone from furnace to craft stone bricks, turtle 2 of 2]]
  3.  
  4. print('Starting stone brick crafting program...')
  5.  
  6. local NUM_FURNACES = 5
  7. local brickCount = 0
  8. while true do
  9. -- check turtle's fuel
  10. if turtle.getFuelLevel() < (2 * NUM_FURNACES) then
  11. error('Turtle needs more fuel!')
  12. end
  13.  
  14. turtle.select(1) -- put stone in slot 1
  15.  
  16. -- start collecting stone from furnaces
  17. for i = 1, NUM_FURNACES do
  18. turtle.suckUp(64 - turtle.getItemCount(1)) -- get stone from furnace
  19. if turtle.getItemCount(1) == 64 then
  20. break -- stop once there are 64 stone blocks
  21. end
  22. if i ~= NUM_FURNACES then
  23. turtle.back() -- move to next furnace
  24. end
  25. end
  26.  
  27. -- craft stone bricks
  28. if turtle.getItemCount(1) == 64 then
  29. turtle.transferTo(2, 16) -- put in slot 2
  30. turtle.transferTo(5, 16) -- put in slot 5
  31. turtle.transferTo(6, 16) -- put in slot 6
  32. turtle.select(16) -- stone bricks to go in slot 16
  33. turtle.craft() -- craft stone bricks
  34. brickCount = brickCount + 64
  35. print('Total stone bricks: ' .. brickCount)
  36. else
  37. print('Not enough stone yet. Sleeping...')
  38. os.sleep(120) -- wait for 2 minutes
  39. end
  40.  
  41. -- move back to chest (by first furnace)
  42. for i = 1, NUM_FURNACES - 1 do
  43. turtle.forward()
  44. end
  45. turtle.turnLeft() -- face chest
  46. turtle.select(16) -- select stone bricks
  47. turtle.drop() -- put stone bricks into chest
  48. turtle.turnRight() -- face generator again
  49. end
Add Comment
Please, Sign In to add comment