Advertisement
awesome8digger

Computercraft MegaSpruceFarm

Sep 24th, 2017 (edited)
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.63 KB | None | 0 0
  1. leafDecayTime = 10
  2.  
  3. function forward(dist)
  4.     refuelTo(dist)
  5.     for i = 1, dist do
  6.         while turtle.forward() == false do
  7.             if turtle.dig() == false then
  8.                 turtle.attack()
  9.             end
  10.         end
  11.     end
  12. end
  13.  
  14. function up(dist)
  15.     refuelTo(dist)
  16.     for i = 1, dist do
  17.         while turtle.up() == false do
  18.             if turtle.digUp() == false then
  19.                 turtle.attackUp()
  20.             end
  21.         end
  22.     end
  23. end
  24.  
  25. function down(dist)
  26.     refuelTo(dist)
  27.     for i = 1, dist do
  28.         while turtle.down() == false do
  29.             if turtle.digDown() == false then
  30.                 turtle.attackDown()
  31.             end
  32.         end
  33.     end
  34. end
  35.  
  36. function refuelTo(level)
  37.     turtle.select(1)
  38.     while turtle.getFuelLevel() < level do
  39.         if turtle.refuel(1) == false then
  40.             print("No Fuel! Add more to continue.")
  41.             while turtle.refuel(1) == false do
  42.                 os.sleep(5)
  43.             end
  44.         end
  45.     end
  46. end
  47.  
  48. function digForward(dist)
  49.     for i = 1, dist do
  50.         forward(1)
  51.         turtle.digUp()
  52.         turtle.digDown()
  53.     end
  54. end
  55.  
  56.  
  57.  
  58.  
  59. function buildFarm()
  60.     placeSetupArea()
  61.     forward(1)
  62.     turtle.turnLeft()
  63.     forward(4)
  64.     turtle.turnRight()
  65.     down(2)
  66.     turtle.digDown()
  67.     digFarm()
  68.     turtle.turnRight()
  69.     forward(4)
  70.     turtle.turnRight()
  71.     forward(4)
  72.     down(1)
  73.     placeWater()
  74.     turtle.turnRight()
  75.     forward(4)
  76.     turtle.turnRight()
  77.     forward(4)
  78.     placeDirt()
  79.     forward(4)
  80.     up(2)
  81.     forward(1)
  82.     dropExtraItems()
  83.     turtle.turnLeft()
  84.     turtle.turnLeft()
  85. end
  86.  
  87. function drawFarmTop()
  88.     print("############")
  89.     print("#W        W#")
  90.     print("#          #")
  91.     print("#          #")
  92.     print("#          #")
  93.     print("#    DD    #")
  94.     print("#    DD    #")
  95.     print("#          #")
  96.     print("#          #")
  97.     print("#          #")
  98.     print("#W        W#")
  99.     print("####CTC#####")
  100.     print("#####C######")
  101. end
  102.  
  103. function drawFarmSide()
  104.     print("    ####    ")
  105.     print("   ######   ")
  106.     print("  ########  ")
  107.     print("  ########  ")
  108.     print("     ||     ")
  109.     print("     ||     ")
  110.     print("     C|     ")
  111.     print("    CTC     ")
  112.     print("#    CD    #")
  113.     print("#          #")
  114.     print("#W        W#")
  115.     print("############")
  116. end
  117.  
  118. function placeSetupArea()
  119.     turtle.select(2)
  120.     turtle.digDown()
  121.     turtle.placeDown()
  122.     turtle.digUp()
  123.     turtle.placeUp()
  124.     turtle.turnLeft()
  125.     turtle.dig()
  126.     turtle.place()
  127.     turtle.turnRight()
  128.     turtle.turnRight()
  129.     turtle.dig()
  130.     turtle.place()
  131.     turtle.turnRight()
  132.     turtle.dig()
  133.     turtle.select(3)
  134.     turtle.place()
  135.     turtle.turnRight()
  136.     turtle.turnRight()
  137. end
  138.  
  139. function digFarm()
  140.     for i = 1, 10 do
  141.         digForward(9)
  142.         if i == 10 then
  143.             break
  144.         elseif i % 2 == 1 then
  145.             turtle.turnRight()
  146.             digForward(1)
  147.             turtle.turnRight()
  148.         else
  149.             turtle.turnLeft()
  150.             digForward(1)
  151.             turtle.turnLeft()
  152.         end
  153.     end
  154. end
  155.  
  156. function placeWater()
  157.     turtle.digDown()
  158.     forward(1)
  159.     turtle.digDown()
  160.     turtle.select(5)
  161.     turtle.placeDown()
  162.     turtle.turnLeft()
  163.     forward(1)
  164.     turtle.digDown()
  165.     turtle.turnLeft()
  166.     forward(1)
  167.     turtle.digDown()
  168.     turtle.select(6)
  169.     turtle.placeDown()
  170.  
  171.     os.sleep(1)
  172.     turtle.select(6)
  173.     turtle.placeDown()
  174.     os.sleep(1)
  175.     turtle.select(5)
  176.     turtle.placeDown()
  177.     up(1)
  178.     forward(4)
  179.     turtle.turnRight()
  180.     forward(4)
  181.     turtle.select(5)
  182.     turtle.placeDown()
  183.     turtle.select(6)
  184.     turtle.turnRight()
  185.     forward(9)
  186.     turtle.select(6)
  187.     turtle.placeDown()
  188.     turtle.turnRight()
  189.     forward(5)
  190.     turtle.turnRight()
  191.     forward(4)
  192.     down(1)
  193.     turtle.turnLeft()
  194.     turtle.turnLeft()
  195.     os.sleep(1)
  196.     turtle.select(6)
  197.     turtle.placeDown()
  198.     os.sleep(1)
  199.     turtle.select(5)
  200.     turtle.placeDown()
  201.     up(1)
  202.     forward(4)
  203.     turtle.turnRight()
  204.     forward(4)
  205.     turtle.select(5)
  206.     turtle.placeDown()
  207.     turtle.select(6)
  208.     turtle.turnRight()
  209.     forward(9)
  210.     turtle.select(6)
  211.     turtle.placeDown()
  212. end
  213.  
  214. function placeDirt()
  215.     turtle.select(4)
  216.     turtle.placeUp()
  217.     forward(1)
  218.     turtle.select(4)
  219.     turtle.placeUp()
  220.     turtle.turnLeft()
  221.     forward(1)
  222.     turtle.turnLeft()
  223.     turtle.select(4)
  224.     turtle.placeUp()
  225.     forward(1)
  226.     turtle.select(4)
  227.     turtle.placeUp()
  228. end
  229.  
  230. function dropExtraItems()
  231.     for i = 2, 16 do
  232.         turtle.select(i)
  233.         turtle.drop()
  234.     end
  235. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement