asweigart

cobminer

Jul 29th, 2016
585
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. --[[Stone Brick Factory program by Al Sweigart
  2. Mines cobblestone from a generator, turtle 1 of 2]]
  3.  
  4. os.loadAPI('hare') -- load the hare module
  5. local numToDrop
  6. local NUM_FURNACES = 5
  7.  
  8. print('Starting mining program...')
  9. while true do
  10. -- mine cobblestone
  11. if turtle.detect() then
  12. print('Cobblestone detected. Mining...')
  13. turtle.dig() -- mine cobblestone
  14. else
  15. print('No cobblestone. Sleeping...')
  16. os.sleep(0.5) -- half-second pause
  17. end
  18.  
  19. -- check for a full stack of cobblestone
  20. hare.selectItem('minecraft:cobblestone')
  21. if turtle.getItemCount() == 64 then
  22. -- check turtle's fuel
  23. if turtle.getFuelLevel() < (2 * NUM_FURNACES) then
  24. error('Turtle needs more fuel!')
  25. end
  26.  
  27. -- put cobblestone in furnaces
  28. print('Dropping off cobblestone...')
  29. for furnacesToFill = NUM_FURNACES, 1, -1 do
  30. turtle.back() -- move over furnace
  31. numToDrop = math.floor(turtle.getItemCount() / furnacesToFill)
  32. turtle.dropDown(numToDrop) -- put cobblestone in furnace
  33. end
  34.  
  35. -- move back to cobblestone generator
  36. for moves = 1, NUM_FURNACES do
  37. turtle.forward()
  38. end
  39.  
  40. if turtle.getItemCount() > 0 then
  41. print('All furnaces full. Sleeping...')
  42. os.sleep(300) -- wait for five minutes
  43. end
  44. end
  45. end
Add Comment
Please, Sign In to add comment