TRU3XV3T3R4N

CC Quarry v1.1

Aug 30th, 2013
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.31 KB | None | 0 0
  1. x = 0 --The amount turtle has moved by
  2. t = 0 --Left or right
  3. f = 0 --fuel amount
  4. z = 0 --Size of the square
  5. h = 0 --initial depth
  6. y = 0 --The depth it goes to
  7.  
  8. cyclet = 0 --Use 1 and 2 or 3 and 4
  9. cycles = 0 --1 cycle = a row
  10. oto = 1 --One time only, initial code
  11.  
  12. function init()
  13.     if oto == 1 then
  14.         f = turtle.getFuelLevel()
  15.         if f == 0 then
  16.             turtle.select(16)
  17.             turtle.refuel(64)
  18.             turtle.select(1)
  19.             rednet.broadcast("Turtle is ready!")
  20.             oto = 0
  21.            
  22. end
  23.     end
  24.         end
  25.  
  26. --function question()
  27. --  if oto == 1 then
  28. --      print("What size square are you hoping for?")
  29. --      z = tonumber(read())
  30. --end
  31. --  end
  32.  
  33.  
  34.  
  35. function main()
  36.     if x < 8 then
  37.         while x < 8 do
  38.             turtle.dig()
  39.             turtle.forward()
  40.             x = x + 1
  41. end
  42.     end
  43.         end
  44.  
  45. function cycleCounter()
  46.     if x == 8 then
  47.         cycles = cycles + 1
  48.         print(cycles)
  49. end
  50.     end
  51.  
  52. function turn()
  53.     if x == 8 then
  54.         if cyclet == 0 then
  55.             if t == 0 then
  56.                 while x == z do
  57.                     print("turn one")
  58.                     turtle.turnRight()
  59.                     turtle.dig()
  60.                     turtle.forward()
  61.                     turtle.turnRight()
  62.                     x = 0
  63.                     t = 1
  64. end
  65.     end
  66.         end
  67.             end
  68.                 end
  69.  
  70. function turnTwo()
  71.     if x == 8 then
  72.         if cyclet == 0 then
  73.             if t == 1 then
  74.                 while x == z do
  75.                     print("turn two")
  76.                     turtle.turnLeft()
  77.                     turtle.dig()
  78.                     turtle.forward()
  79.                     turtle.turnLeft()
  80.                     x = 0
  81.                     t = 0
  82. end
  83.     end
  84.         end
  85.             end
  86.                 end
  87.  
  88. function endCycle()
  89.     if cycles == 8 then
  90.         turtle.digDown()
  91.         turtle.down()
  92.         turtle.turnLeft()
  93.         turtle.turnLeft()
  94.         y = y - 1
  95.         cycles = 0
  96.         t = 0
  97.         x = 0
  98.         print("new cycle")
  99.         if cyclet == 0 then
  100.             cyclet = 1
  101.         else
  102.             cyclet = 0
  103. end
  104.     end
  105.         end
  106.  
  107. function turnThree()
  108.     if x == 8 then
  109.         if cyclet == 1 then
  110.             if t == 0 then
  111.                 while x == 8 do
  112.                     print("turn three")
  113.                     turtle.turnLeft()
  114.                     turtle.dig()
  115.                     turtle.forward()
  116.                     turtle.turnLeft()
  117.                     x = 0
  118.                     t = 1
  119. end
  120.     end
  121.         end
  122.             end
  123.                 end
  124.  
  125. function turnFour()
  126.     if x == 8 then
  127.         if cyclet == 1 then
  128.             if t == 1 then
  129.                 while x == z do
  130.                     print("turn four")
  131.                     turtle.turnRight()
  132.                     turtle.dig()
  133.                     turtle.forward()
  134.                     turtle.turnRight()
  135.                     x = 0
  136.                     t = 0
  137. end
  138.     end
  139.         end
  140.             end
  141.                 end
  142.  
  143. while true do
  144.     --question()
  145.     init()
  146.     main()
  147.     cycleCounter()
  148.     endCycle()
  149.     turn()
  150.     turnTwo()
  151.     turnThree()
  152.     turnFour()
  153. end
Advertisement
Add Comment
Please, Sign In to add comment