Advertisement
Guest User

build.lua

a guest
May 22nd, 2020
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.08 KB | None | 0 0
  1. Fuel=16
  2. blocksused = 0
  3. length = 8
  4. clusters = 3
  5. hight = 3
  6. spacex=4
  7. spacey=3 --for farm this would be 3 but its impo
  8.  
  9. function checkFuel()
  10.     if turtle.getFuelLevel() < 400 then
  11.         turtle.select(Fuel)
  12.         turtle.refuel(5)
  13.     end
  14. end
  15. function up(i) --turtle.up() 3 times, i times
  16.     for j=1,i,1 do
  17.         for k=1,spacey,1 do
  18.             turtle.up()
  19.         end
  20.     end
  21. end
  22. function down(i)
  23.     for j=1,i,1 do
  24.         for k=1,spacey,1 do
  25.             turtle.down()
  26.         end
  27.     end
  28. end
  29. function left(i)
  30.     turtle.turnLeft()
  31.     for j=1,i,1 do
  32.         for k=1,spacex,1 do
  33.             turtle.forward()
  34.         end
  35.     end
  36.     turtle.turnRight()
  37. end
  38. function right(i)
  39.     turtle.turnRight()
  40.     for j=1,i,1 do
  41.         for k=1,spacex,1 do
  42.             turtle.forward()
  43.         end
  44.     end
  45.     turtle.turnLeft()
  46. end
  47. function placeDirt(down)
  48.     checkFuel()
  49.     if blocksused/64 == 15 then --this checks if empty
  50.         print("Refill me with dirt then press enter")
  51.         temp = io.read()
  52.         blocksused = 0
  53.     end
  54.     turtle.select((blocksused/64)+1)
  55.     if down then turtle.placeDown()
  56.     else turtle.place() end
  57.     blocksused = blocksused+1
  58. end
  59. function rotate(i)
  60.     for j=1,i,1 do
  61.         turtle.turnLeft()
  62.     end
  63. end    
  64. function buildSegment()
  65.     if not turtle.detectDown() then
  66.         placeDirt(true)
  67.     end
  68.     rotate(1)
  69.     placeDirt()
  70.     rotate(2)
  71.     placeDirt()
  72.     rotate(1)
  73. end
  74. function buildLine()
  75.     rotate(2)
  76.     placeDirt() --make a stopper
  77.     rotate(2)
  78.     turtle.forward() --prepare to start
  79.     for i=1,length,1 do
  80.         buildSegment()
  81.         if i==length then
  82.             placeDirt()
  83.             turtle.up()
  84.             placeDirt()
  85.             turtle.down() --stopper for farm
  86.         else turtle.forward() end
  87.     end
  88.     rotate(2)
  89.     while not turtle.detect() do
  90.         turtle.forward()
  91.     end
  92.     turtle.up()
  93.     placeDirt()
  94.     turtle.down()
  95.     rotate(2)
  96.     placeDirt()
  97. end
  98. function firstLayer()
  99.     rotate(2)
  100.     placeDirt()
  101.     rotate(2)
  102.     for i=1,length,1 do
  103.         turtle.forward()
  104.         turtle.digDown()
  105.     end
  106.     turtle.place()
  107.     rotate(2)
  108.     while not turtle.detect() do
  109.         turtle.forward()
  110.     end
  111.     rotate(2)
  112. end
  113. function buildCluster()
  114.     for i=1,hight-1,1 do
  115.         buildLine()
  116.         if i==hight-1 then down(hight-2)
  117.         else up(1) end
  118.     end
  119. end
  120. --SETUP
  121. print("how many clusters?")
  122. print("small ~2-3, medium ~4-5,large ~6-7")
  123. clusters = tonumber(io.read())
  124. print("how long should the farm be?")
  125. length = tonumber(io.read())
  126. print("how tall?")
  127. hight = tonumber(io.read())
  128. print("fill all slots with dirt except slot 16\n fill slot 16 with fuel")    
  129. print("press enter to build")
  130. temp = io.read()        
  131.  
  132. --CODE STARTS HERE
  133. for i=1,clusters,1 do
  134.     firstLayer()
  135.     right(1)
  136. end
  137. left(clusters)
  138. up(1)
  139. turtle.down()
  140. for k=1,clusters,1 do
  141.     buildCluster()
  142.     if k==clusters then left(clusters-1)
  143.     else right(1) end
  144. end
  145. down(1)
  146. print("now add water and hoe the dirt and i'll be ready to farm")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement