Advertisement
jordonbc

TESTING SM

Oct 11th, 2018
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. -- This Version
  2. -- 2.13 10/11/2014
  3. -- ChangeLogs
  4. -- 2.04 - Adding Left or Right Support
  5. -- 2.05 - Changing Lot Code For Some Stable And Cleaner Code
  6. -- 2.06 - Ops Forget Fuel Chcking Code after rewrtitting
  7. -- 2.07 - Woops My Bad i wrote back() not Back()
  8. -- 2.08 - Fixing Imputs
  9. -- 2.09 - Forget That i change remove line of code since i use local function now
  10. -- 2.10 - Minor error with back that it leave one block in wall
  11. --    Change: Torch spacing to 8 from 10
  12. -- 2.11 - Change: Right to left and Left to Right better understand
  13. -- 2.12 - Add Stop Code when item are gone
  14. -- 2.13 - i made big mistake i forget to end to new stop code
  15. -- ToDoList
  16. -- Add Code to place torch each time it starts
  17. -- Add Fuel Code so can know almost how much fuel you need
  18. -- Add second fuel slot if you go allout diggin
  19. -- Mabye add code that make turtle make new line of tunnels
  20.  
  21. --Local
  22. local distance = 0 -- How Far Did User Pick
  23. local onlight = 0 -- When to Place Torch
  24. local torch = 0 -- How many items are in slot 1 (torch)
  25. -- local torch = turtle.getItemCount(1) -- How many items are in slot 1 (torch)
  26. local chest = turtle.getItemCount(2) -- How many items are in slot 2 (chest)
  27. local ItemFuel = turtle.getItemCount(3) -- How many items are in slot 3 (Fuel)
  28. local MD = 3 -- How Many Blocks Apart From Each Mine
  29. local MineTimes = 0 -- If Multi Mines Are ON then This will keep Count
  30. local Fuel = 0 -- if 2 then it is unlimited no fuel needed
  31. local NeedFuel = 0 -- If Fuel Need Then 1 if not Then 0
  32. local Error = 0 -- 0 = No Error and 1 = Error
  33. local Way = 0 -- 0 = Left and 1 = Right
  34.  
  35. --Checking
  36. local function Check()
  37.     if chest == 0 then
  38.         print("there are no chests")
  39.         Error = 1
  40.     else
  41.         print("There are chest in turtle")
  42.     end
  43.     if ItemFuel == 0 then
  44.         print("No Fuel Items")
  45.         error = 1
  46.     else
  47.         print("there is fuel")
  48.     end
  49.     repeat
  50.         if turtle.getFuelLevel() == "unlimited" then
  51.             print("NO NEED FOR FUEL")
  52.             Needfuel = 0
  53.         elseif turtle.getFuelLevel() < 100 then
  54.             turtle.select(3)
  55.             turtle.refuel(1)
  56.             Needfuel = 1
  57.             ItemFuel = ItemFuel - 1
  58.         elseif NeedFuel == 1 then
  59.             Needfuel = 0
  60.         end
  61.     until NeedFuel == 0
  62. end
  63.  
  64. -- Recheck if user forget something turtle will check after 15 sec
  65. local function Recheck()
  66.     -- torch = turtle.getItemCount(1)
  67.     chest = turtle.getItemCount(2)
  68.     ItemFuel = turtle.getItemCount(3)
  69.     Error = 0
  70. end
  71.  
  72. --Mining
  73. local function ForwardM()
  74.     repeat
  75.         if turtle.detect() then
  76.             turtle.dig()
  77.         end
  78.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  79.             TF = TF - 1
  80.             onlight = onlight + 1
  81.         end
  82.         if turtle.detectUp() then
  83.             turtle.digUp()
  84.         end
  85.         turtle.select(4)
  86.         turtle.placeDown()
  87.         if onlight == 8 then -- Every 10 Block turtle place torch
  88.             if torch > 0 then
  89.                 turtle.turnLeft()
  90.                 turtle.turnLeft()
  91.                 turtle.select(1)
  92.                 turtle.place()
  93.                 turtle.turnLeft()
  94.                 turtle.turnLeft()
  95.                 -- torch = torch - 1
  96.                 onlight = onlight - 8
  97.             else
  98.                 print("turtle run out of torchs")
  99.                 os.shutdown()
  100.             end
  101.         end
  102.         if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  103.             if chest > 0 then
  104.                 turtle.select(2)
  105.                 turtle.digDown()
  106.                 turtle.placeDown()
  107.                 chest = chest - 1
  108.                 for slot = 5, 16 do
  109.                     turtle.select(slot)
  110.                     turtle.dropDown()
  111.                     sleep(1.5)
  112.                 end
  113.                 turtle.select(5)
  114.             else
  115.                 print("turtle run out of chest")
  116.                 os.shutdown()
  117.             end
  118.         end
  119.         repeat
  120.             if turtle.getFuelLevel() == "unlimited" then
  121.                 print("NO NEED FOR FUEL")
  122.                 Needfuel = 0
  123.             elseif turtle.getFuelLevel() < 100 then
  124.                 turtle.select(3)
  125.                 turtle.refuel(1)
  126.                 Needfuel = 1
  127.                 ItemFuel = ItemFuel - 1
  128.             elseif ItemFuel == 0 then
  129.                 print("turtle run out of fuel")
  130.                 os.shutdown()
  131.             elseif NeedFuel == 1 then
  132.                 Needfuel = 0
  133.             end
  134.         until NeedFuel == 0
  135.     until TF == 0
  136. end
  137.  
  138. --Warm Up For Back Program
  139. local function WarmUpForBackProgram() -- To make turn around so it can go back
  140.     turtle.turnLeft()
  141.     turtle.turnLeft()
  142.     turtle.up()
  143. end
  144.  
  145. --Back Program
  146. local function Back()
  147.     repeat
  148.         if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  149.             TB = TB - 1
  150.         end
  151.         if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  152.             if TB ~= 0 then
  153.                 turtle.dig()
  154.             end
  155.         end
  156.     until TB == 0
  157. end
  158.  
  159. -- Multimines Program
  160. local function MultiMines()
  161.     if Way == 1 then
  162.         turtle.turnLeft()
  163.         turtle.down()
  164.     else
  165.         turtle.turnRight()
  166.         turtle.down()
  167.     end
  168.     repeat
  169.         if turtle.detect() then
  170.             turtle.dig()
  171.         end
  172.         if turtle.forward() then
  173.             MD = MD - 1
  174.         end
  175.         if turtle.detectUp() then
  176.             turtle.digUp()
  177.         end
  178.     until MD == 0
  179.     if Way == 1 then
  180.         turtle.turnLeft()
  181.     else
  182.         turtle.turnRight()
  183.     end
  184.     if MineTimes == 0 then
  185.         print("Turtle is done")
  186.     else
  187.         MineTimes = MineTimes - 1
  188.     end
  189. end
  190.  
  191. -- Restart
  192. local function Restart()
  193.     TF = distance
  194.     TB = distance
  195.     MD = 3
  196.     onlight = 0
  197. end
  198.  
  199. -- EmptyInv
  200. function EmptyInv()
  201. if turtle.getItemCount(16) ~= 0 then
  202.  turtle.dig()
  203.  turtle.select(1)
  204.  turtle.place()
  205.  for i = 2,16 do
  206.    turtle.select(i)
  207.    turtle.drop()
  208.  end
  209.  turtle.select(1)
  210.  turtle.dig()
  211. end
  212. end
  213.  
  214. -- Starting
  215. function Start()
  216.     repeat
  217.         ForwardM()
  218.         WarmUpForBackProgram()
  219.         Back()
  220.         MultiMines()
  221.         EmptyInv()
  222.         Restart()
  223.     until MineTimes == 0
  224. end
  225.  
  226. -- Start
  227. print("Hi There Welcome to Mining Turtle Program")
  228. print("How Far Will Turtle Go")
  229. input = io.read()
  230. distance = tonumber(input)
  231. TF = distance
  232. TB = distance
  233. print("Left or Right")
  234. print("0 = Left and 1 = Right")
  235. input2 = io.read()
  236. Way = tonumber(input2)
  237. print("How Many Times")
  238. input3 = io.read()
  239. MineTimes = tonumber(input3)
  240. Check()
  241. if Error == 1 then
  242.     repeat
  243.         sleep(10)
  244.         Recheck()
  245.         Check()
  246.     until Error == 0
  247. end
  248. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement