daily pastebin goal
30%
SHARE
TWEET

ComputerCraft Tutorial: fortune_block_breaker_0_1

hevohevo Feb 23rd, 2014 2,523 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- ######################################
  2. -- Fortune Block Breaker
  3. -- version 0.1
  4. -- http://hevohevo.hatenablog.com/
  5. -- This Program requires a Fortune Mining Turtle by "More Turtles" mod
  6. --  http://www.computercraft.info/forums2/index.php?/topic/16465-mc164152-more-turtles-v112/
  7.  
  8. -- Side view
  9. -- T: fortune mining turtle, B: chest for blocks, I: chest for items
  10. --   B
  11. --   T
  12. --   I
  13.  
  14. -- Config
  15. FUEL_SLOT = 16
  16. BLOCK_SLOT = 1
  17.  
  18. local p = peripheral.wrap("right")
  19. assert((p and p.digFortune), "required Fortune Mining Turtle")
  20.  
  21. -- Functions
  22. function myRefuel()
  23.   turtle.select(FUEL_SLOT)
  24.   turtle.refuel()
  25.   print("Fuel: ",turtle.getFuelLevel())
  26. end
  27.  
  28. function suckBlock() -- return true/false
  29.   turtle.select(BLOCK_SLOT)
  30.   return turtle.suckUp()
  31. end
  32.  
  33. function placeDig(count)
  34.   turtle.select(BLOCK_SLOT)
  35.   for i=1,count do
  36.     assert(turtle.place())
  37.     assert(p.digFortune())
  38.   end
  39. end
  40.  
  41. function dropAll(start, goal)
  42.   for i=start, goal do
  43.     turtle.select(i)
  44.     turtle.dropDown()
  45.   end
  46. end
  47.  
  48. -- Main
  49. myRefuel()
  50.  
  51. while suckBlock() do
  52.   placeDig(turtle.getItemCount(BLOCK_SLOT))
  53.   dropAll(1,16)
  54. end
  55. print("Finished: fuel ",turtle.getFuelLevel())
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand