Advertisement
strachpr01

Strip Mine Turtle [os 1.3]

Sep 22nd, 2017
421
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.55 KB | None | 0 0
  1. --Local
  2. local distance = 0 -- How Far Did User Pick
  3. local onlight = 0 -- When to Place Torch
  4. local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
  5. local MD = 3 -- How Many Blocks Apart From Each Mine
  6. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  7. local Error = 0 -- 0 = No Error and 1 = Error
  8. local Way = 0 -- 0 = Left and 1 = Right
  9.  
  10. --Checking
  11. local function Check()
  12.     if torch == 0 then
  13.         print("There are no torch's in Turtle")
  14.         Error = 1
  15.     else
  16.         print("There are torch's in turtle")
  17.     end
  18. end
  19.  
  20. -- Recheck if user forget something turtle will check after 15 sec
  21. local function Recheck()
  22.     torch = turtle.getItemCount(1)
  23.     Error = 0
  24. end
  25.  
  26. --Mining
  27. local function ForwardM()
  28.     repeat
  29.         if turtle.detect() then
  30.             turtle.dig()
  31.         end
  32.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  33.             TF = TF - 1
  34.             onlight = onlight + 1
  35.         end
  36.         if turtle.detectUp() then
  37.             turtle.digUp()
  38.         end
  39.         turtle.up()
  40.         if turtle.detectUp() then
  41.             turtle.digUp()
  42.         end
  43.         turtle.down()
  44.         turtle.select(2)
  45.         repeat
  46.             turtle.placeDown()
  47.             sleep(0.2)
  48.         until turtle.detectDown()
  49.         if onlight == 8 then -- Every 10 Block turtle place torch
  50.             if torch > 0 then
  51.                 turtle.turnLeft()
  52.                 turtle.turnLeft()
  53.                 turtle.select(1)
  54.                 turtle.place()
  55.                 turtle.turnLeft()
  56.                 turtle.turnLeft()
  57.                 torch = torch - 1
  58.                 onlight = onlight - 8
  59.             else
  60.                 print("turtle run out of torchs")
  61.                 os.shutdown()
  62.             end
  63.         end
  64.         if turtle.getItemCount(9)>0 then -- If slot 9 in turtle has item slot 4 to 9 will go to chest
  65.             print("Waiting to be emptied")
  66.             repeat
  67.                 sleep(10)
  68.             until turtle.getItemCount(9) == 0
  69.         end
  70.     until TF == 0
  71. end
  72.  
  73. --Warm Up For Back Program
  74. local function WarmUpForBackProgram() -- To make turn around so it can go back
  75.     turtle.turnLeft()
  76.     turtle.turnLeft()
  77.     turtle.up()
  78. end
  79.  
  80. --Back Program
  81. local function Back()
  82.     repeat
  83.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  84.             TB = TB - 1
  85.         end
  86.         if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  87.             if TB ~= 0 then
  88.                 turtle.dig()
  89.             end
  90.         end
  91.     until TB == 0
  92. end
  93.  
  94. -- Multimines Program
  95. local function MultiMines()
  96.     if Way == 1 then
  97.         turtle.turnLeft()
  98.         turtle.down()
  99.     else
  100.         turtle.turnRight()
  101.         turtle.down()
  102.     end
  103.     repeat
  104.         if turtle.detect() then
  105.             turtle.dig()
  106.         end
  107.         if turtle.forward() then
  108.             MD = MD - 1
  109.         end
  110.         if turtle.detectUp() then
  111.             turtle.digUp()
  112.         end
  113.     until MD == 0
  114.     if Way == 1 then
  115.         turtle.turnLeft()
  116.     else
  117.         turtle.turnRight()
  118.     end
  119.     if MineTimes == 0 then
  120.         print("Turtle is done")
  121.     else
  122.         MineTimes = MineTimes - 1
  123.     end
  124. end
  125.  
  126. -- Restart
  127. local function Restart()
  128.     TF = distance
  129.     TB = distance
  130.     MD = 3
  131.     onlight = 0
  132. end
  133.  
  134. -- Starting
  135. function Start()
  136.     repeat
  137.         ForwardM()
  138.         WarmUpForBackProgram()
  139.         Back()
  140.         MultiMines()
  141.         Restart()
  142.     until MineTimes == 0
  143. end
  144.  
  145. -- Start
  146. print("Hi There Welcome to Mining Turtle Program")
  147. print("Designed for turtle os 1.3")
  148. print("Torches go in slot 1")
  149. print("Gravel in slot 2")
  150. print("turtle will stop and wait when it needs to be emptied")
  151. print("How Far Will Turtle Go")
  152. input = io.read()
  153. distance = tonumber(input)
  154. TF = distance
  155. TB = distance
  156. print("Left or Right")
  157. print("0 = Left and 1 = Right")
  158. input2 = io.read()
  159. Way = tonumber(input2)
  160. print("How Many Times")
  161. input3 = io.read()
  162. MineTimes = tonumber(input3)
  163. Check()
  164. if Error == 1 then
  165.     repeat
  166.         sleep(10)
  167.         Recheck()
  168.         Check()
  169.     until Error == 0
  170. end
  171. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement