Advertisement
Guest User

Untitled

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