Advertisement
Guest User

Strip

a guest
Jul 23rd, 2014
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.20 KB | None | 0 0
  1. local distance = 0 -- the distance you want turtle to go
  2. local onlight = 0
  3. local torch = turtle.getItemCount(1) -- Checks the amount of torches in slot 1
  4. local chest = turtle.getItemCount(2) -- Checks the amount of chests in slot 2
  5. local ItemFuel = turtle.getItemCount(3) -- Checks the amount of Coal in slot 3
  6. local Fuel = 0
  7. local NeedFuel = 0
  8. local Error = 0
  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 :D")
  17.   end
  18.   if chest == 0 then
  19.     print("there are no chests :(")
  20.     Error = 1
  21.   else
  22.     print("There are chest in turtle :D")
  23.   end
  24.   if ItemFuel == 0 then
  25.     print("No Fuel Items :(")
  26.     error = 1
  27.   else
  28.     print("there is fuel :D")
  29.   end
  30.   repeat
  31.     if turtle.getFuelLevel() == "unlimited" then
  32.       print("NO NEED FOR FUEL")
  33.       Needfuel = 0
  34.     elseif turtle.getFuelLevel() < 100 then
  35.       turtle.select(3)
  36.       turtle.refuel(1)
  37.       Needfuel = 1
  38.       ItemFuel = ItemFuel - 1
  39.     elseif NeedFuel == 1 then
  40.       Needfuel = 0
  41.     end
  42.   until NeedFuel == 0
  43. end
  44.  
  45. local function Recheck()
  46.   torch = turtle.getItemCount(1)
  47.   chest = turtle.getItemCount(2)
  48.   ItemFuel = turtle.getItemCount(3)
  49.   Error = 0
  50. end
  51.  
  52. --Mining
  53. local function ForwardM()
  54.   repeat
  55.     if turtle.detect() then
  56.       turtle.dig()
  57.     end
  58.     if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  59.       TF = TF - 1
  60.       onlight = onlight + 1
  61.     end
  62.     if turtle.detectUp() then
  63.       turtle.digUp()
  64.     end
  65.     turtle.select(4)
  66.     turtle.placeDown()
  67.     if onlight == 10 then -- Every 10 Block turtle place torch
  68.       turtle.turnLeft()
  69.       turtle.turnLeft()
  70.       turtle.select(1)
  71.       turtle.place()
  72.       turtle.turnLeft()
  73.       turtle.turnLeft()
  74.       torch = torch - 1
  75.       onlight = onlight - 10
  76.     end
  77.     if turtle.getItemCount(16)>0 then -- If slot 16 in turtle has item slot 5 to 16 will go to chest
  78.       turtle.select(2)
  79.       for i = 0, 10 do
  80.       turtle.dig()
  81.       sleep(0.5)
  82.       end
  83.       turtle.place()
  84.       chest = chest - 1
  85.       for slot = 5, 16 do
  86.         turtle.select(slot)
  87.         turtle.drop()
  88.         sleep(1.5)
  89.       end
  90.       turtle.select(2)
  91.       turtle.dig()
  92.       turtle.select(5)
  93.     end
  94.     repeat
  95.       if turtle.getFuelLevel() == "unlimited" then
  96.         print("NO NEED FOR FUEL")
  97.         Needfuel = 0
  98.       elseif turtle.getFuelLevel() < 100 then
  99.         turtle.select(3)
  100.         turtle.refuel(1)
  101.         Needfuel = 1
  102.         ItemFuel = ItemFuel - 1
  103.       elseif NeedFuel == 1 then
  104.         Needfuel = 0
  105.       end
  106.     until NeedFuel == 0
  107.   until TF == 0
  108. end
  109.  
  110. --Warm Up For Back Program
  111. local function WarmUpForBackProgram() -- To make turn around so it can go back
  112.   turtle.turnLeft()
  113.   turtle.turnLeft()
  114.   turtle.up()
  115. end
  116.  
  117. --Back Program
  118. local function Back()
  119.   repeat
  120.     if turtle.forward() then -- sometimes sand and gravel and block and mix-up distance
  121.       TB = TB - 1
  122.     end
  123.     if turtle.detect() then -- Sometimes sand and gravel can happen and this will fix it
  124.       turtle.dig()
  125.     end
  126.   until TB == 0
  127. end
  128.  
  129. -- Restart
  130. local function Restart()
  131.   TF = distance
  132.   TB = distance
  133.   onlight = 0
  134. end
  135.  
  136. local function FillEnder()
  137.   turtle.down()
  138.   sleep(1.5)
  139.   turtle.dig()
  140.   sleep(1.5)
  141.   turtle.select(2)
  142.   turtle.place()
  143.     for slot = 4, 16 do
  144.       turtle.select(slot)
  145.       turtle.drop()
  146.       sleep(1.5)
  147.     end
  148. end
  149.  
  150. -- Starting
  151. function Start()
  152.     ForwardM()
  153.     WarmUpForBackProgram()
  154.     Back()
  155.     Restart()
  156.     FillEnder()
  157.     term.clear()
  158.     print("~~~~~~~~~~~~~~~~~~")
  159.     print("I'm Done Master :D")
  160.     print("~~~~~~~~~~~~~~~~~~")
  161. end
  162.  
  163. -- Start
  164. term.clear()
  165. print("Hi There Welcome to the Strip Mining Program")
  166. print("How Far Will Turtle Go")
  167. input = io.read()
  168. distance = tonumber(input)
  169. TF = distance
  170. TB = distance
  171. print("Slot 1 = Torches, Slot 2 = EnderChest, Slot 3 = Coal")
  172. print("When Ready, Say OK")
  173. input2 = io.read()
  174. if input2 == "OK" then
  175. Check()
  176. else
  177. print("I don't understand you...")
  178. end
  179. if Error == 1 then
  180.   repeat
  181.     sleep(10)
  182.     Recheck()
  183.     Check()
  184.   until Error == 0
  185. end
  186. Start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement