Advertisement
Guest User

Untitled

a guest
May 26th, 2015
217
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.85 KB | None | 0 0
  1.  
  2. --Local
  3. local distance = 0 -- How Far Did User Pick
  4. local onlight = 0 -- When to Place Torch
  5. local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
  6. local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
  7. local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
  8. local MD = 3 -- How Many Blocks Apart From Each Mine
  9. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  10. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
  11. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
  12. local Error = 0 -- 0 = No Error and 1 = Error
  13. local Way = 0 -- 0 = Left and 1 = Right
  14.  
  15. --Checking
  16. local function Check()
  17.         if torch == 0 then
  18.                 print("There are no torch's in Turtle")
  19.                 Error = 1
  20.         else
  21.                 print("There are torch's in turtle")
  22.         end
  23.         if chest == 0 then
  24.                 print("there are no chests")
  25.                 Error = 1
  26.         else
  27.                 print("There are chest in turtle")
  28.         end
  29.         if ItemFuel == 0 then
  30.                 print("No Fuel Items")
  31.                 error = 1
  32.         else
  33.                 print("there is fuel")
  34.         end
  35.         repeat
  36.                 if turtle.getFuelLevel() == "unlimited" then
  37.                         print("NO NEED FOR FUEL")
  38.                         Needfuel = 0
  39.                 elseif turtle.getFuelLevel() < 100 then
  40.                         turtle.select(3)
  41.                         turtle.refuel(1)
  42.                         Needfuel = 1
  43.                         ItemFuel = ItemFuel - 1
  44.                 elseif NeedFuel == 1 then
  45.                         Needfuel = 0
  46.                 end
  47.         until NeedFuel == 0
  48. end
  49.  
  50. -- Recheck if user forget something turtle will check after 15 sec
  51. local function Recheck()
  52.         torch = turtle.getItemCount(1)
  53.         chest = turtle.getItemCount(2)
  54.         ItemFuel = turtle.getItemCount(3)
  55.         Error = 0
  56. end
  57.  
  58. --Mining
  59. local function ForwardM()
  60.         repeat
  61.                 if turtle.detect() then
  62.                         turtle.dig()
  63.                 end
  64.                 if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  65.                         TF = TF - 1
  66.                         onlight = onlight + 1
  67.                 end
  68.                 if turtle.detectUp() then
  69.                         turtle.digUp()
  70.                 end
  71.                 turtle.select(4)
  72.                 turtle.placeDown()
  73.                 if onlight == 8 then -- Every 10 Block turtle place torch
  74.                         if torch > 0 then
  75.                                 turtle.turnLeft()
  76.                                 turtle.turnLeft()
  77.                                 turtle.select(1)
  78.                                 turtle.place()
  79.                                 turtle.turnLeft()
  80.                                 turtle.turnLeft()
  81.                                 torch = torch - 1
  82.                                 onlight = onlight - 8
  83.                         else
  84.                                 print("turtle run out of torchs")
  85.                                 os.shutdown()
  86.                         end
  87.                 end
  88.                 if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  89.                         if chest > 0 then
  90.                                 turtle.select(2)
  91.                                 turtle.digDown()
  92.                                 turtle.placeDown()
  93.                                 chest = chest - 1
  94.                                 for slot = 5, 16 do
  95.                                         turtle.select(slot)
  96.                                         turtle.dropDown()
  97.                                         sleep(1.5)
  98.                                 end
  99.                                 turtle.select(5)
  100.                         else
  101.                                 print("turtle run out of chest")
  102.                                 os.shutdown()
  103.                         end
  104.                 end
  105.                 repeat
  106.                         if turtle.getFuelLevel() == "unlimited" then
  107.                                 print("NO NEED FOR FUEL")
  108.                                 Needfuel = 0
  109.                         elseif turtle.getFuelLevel() < 100 then
  110.                                 turtle.select(3)
  111.                                 turtle.refuel(1)
  112.                                 Needfuel = 1
  113.                                 ItemFuel = ItemFuel - 1
  114.                         elseif ItemFuel == 0 then
  115.                                 print("turtle run out of fuel")
  116.                                 os.shutdown()
  117.                         elseif NeedFuel == 1 then
  118.                                 Needfuel = 0
  119.                         end
  120.                 until NeedFuel == 0
  121.         until TF == 0
  122. end
  123.  
  124. --Warm Up For Back Program
  125. local function WarmUpForBackProgram() -- To make turn around so it can go back
  126.         turtle.turnLeft()
  127.         turtle.turnLeft()
  128.         turtle.up()
  129. end
  130.  
  131.  
  132.  -- Return
  133. local function MineOnWayBackl()
  134.         if Way == 1 then
  135.                 turtle.turnLeft()
  136.         else
  137.                 turtle.turnRight()
  138.         end
  139.         repeat
  140.                 if turtle.detect() then
  141.                         turtle.dig()
  142.                 end
  143.                 if turtle.forward() then
  144.                         MD = MD - 1
  145.                 end
  146.                 if turtle.detectUp() then
  147.                         turtle.digUp()
  148.                 end
  149.         until MD == 0
  150.         if Way == 1 then
  151.                 turtle.turnLeft()
  152.         else
  153.                 turtle.turnRight()
  154.         end
  155. end
  156.  
  157. -- --Back Program
  158. -- local function Back()
  159. --         repeat
  160. --                 if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  161. --                         TB = TB - 1
  162. --                 end
  163. --                 if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  164. --                         if TB ~= 0 then
  165. --                                 turtle.dig()
  166. --                         end
  167. --                 end
  168. --         until TB == 0
  169. -- end
  170.  
  171. -- Multimines Program
  172. local function MultiMines()
  173.         if Way == 1 then
  174.                 turtle.turnLeft()
  175.                 turtle.down()
  176.         else
  177.                 turtle.turnRight()
  178.                 turtle.down()
  179.         end
  180.         repeat
  181.                 if turtle.detect() then
  182.                         turtle.dig()
  183.                 end
  184.                 if turtle.forward() then
  185.                         MD = MD - 1
  186.                 end
  187.                 if turtle.detectUp() then
  188.                         turtle.digUp()
  189.                 end
  190.         until MD == 0
  191.         if Way == 1 then
  192.                 turtle.turnLeft()
  193.         else
  194.                 turtle.turnRight()
  195.         end
  196.         if MineTimes == 0 then
  197.                 print("Turtle is done")
  198.         else
  199.                 MineTimes = MineTimes - 1
  200.         end
  201. end
  202.  
  203. -- Restart
  204. local function Restart()
  205.         TF = distance
  206.         TB = distance
  207.         MD = 3
  208.         onlight = 0
  209. end
  210.  
  211.  
  212. -- Starting
  213. function Start()
  214.         repeat
  215.                 ForwardM()
  216.                 WarmUpForBackProgram()
  217.                 MineOnWayBackl()
  218.                 MultiMines()
  219.                 Restart()
  220.         until MineTimes == 0
  221. end
  222.  
  223. -- Start
  224. print("How deep is the turtle going?")
  225. input = io.read()
  226. distance = tonumber(input)
  227. TF = distance
  228. TB = distance
  229. print("Head left or head right?")
  230. print("0 = Left and 1 = Right")
  231. input2 = io.read()
  232. Way = tonumber(input2)
  233. print("How many strip mines?")
  234. input3 = io.read()
  235. MineTimes = tonumber(input3)
  236. Check()
  237. if Error == 1 then
  238.         repeat
  239.                 sleep(10)
  240.                 Recheck()
  241.                 Check()
  242.         until Error == 0
  243. end
  244. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement