Advertisement
Guest User

Untitled

a guest
Aug 25th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.77 KB | None | 0 0
  1. local times = ""
  2. local FuelNeeded   -- Minimum level of fuel allowed for turtle to start
  3. local Chest = 0    -- Declaring a chest value to determine if chest should be place in the end
  4.  
  5.  
  6.  
  7. sleep (1)
  8. print ("Turtle will mine 1 block in front, and one to its left. Please use Ctrl+t to terminate and move the turtle")
  9. sleep (2)
  10. print ("Mining turtle wants to dig a 1x2 tunnel. Agree? y/n")
  11. local event, agreeToDig = os.pullEvent("char")
  12. if agreeToDig == "y" then
  13.    print ("Starting the program...")
  14.    sleep (1)
  15.    print ("How long do you wish to tunnel?")
  16.    times = read()
  17.  
  18.  
  19.    print ("Do you wish to place a chest and dump items when done mining? (note: Chest must be in slot 16) y/n")
  20.    local event, checkChest = os.pullEvent("char")
  21.    if checkChest == "y" then
  22.       print ("Will place a chest at the end and dump items into it when done mining")
  23.       Chest = Chest+2
  24.    else
  25.       print ("Do you wish to use pre-placed chest at the end? y/n")
  26.       local event, checkChest1 = os.pullEvent("char")
  27.       if checkChest1 == "y" then
  28.          Chest = Chest+1
  29.       else
  30.          print ("Will keep items in turtle...")
  31.          Chest = Chest+3    
  32.       end
  33.    end
  34.    
  35.    FuelNeeded = times*4+1
  36.    print ("Fuel needed to dig is "..FuelNeeded)
  37.  
  38.    if turtle.getFuelLevel() < FuelNeeded then
  39.       print ("Fuel level is: "..turtle.getFuelLevel())
  40.       print ("Turtle is low on fuel. Do you wish to refuel? y/n")
  41.       local event, param1 = os.pullEvent("char")
  42.       if param1 == "y" then
  43.          turtle.select(1)  
  44.          turtle.refuel()
  45.          
  46.       else
  47.          print ("!Too low fuel for program to initiate!")
  48.          print ("Turtle rebooting!")
  49.          sleep (2)
  50.          os.reboot()
  51.          
  52.       end
  53.    end
  54.  
  55.    for i = 1, times do
  56.       print ("Current fuel level is: "..turtle.getFuelLevel())
  57.       turtle.select(2)
  58.      
  59.       turtle.dig()
  60.       while turtle.detect() do
  61.          turtle.dig()
  62.       end
  63.       while not turtle.forward() do
  64.          turtle.dig()
  65.       end
  66.       turtle.digUp()
  67.       while turtle.detectUp() do
  68.          turtle.digUp()
  69.       end
  70.    end
  71.    times = times+1
  72.    turtle.turnLeft()
  73.    turtle.turnLeft()
  74.  
  75.    for i = 1, times do
  76.       while not turtle.forward() do
  77.          sleep (1)
  78.       end
  79.       if (i-1) % 13 == 0 then
  80.         turtle.select(16)
  81.         turtle.placeUp()
  82.         turtle.select(2)
  83.       end
  84.    end
  85. else
  86.    shell.exit()
  87. end
  88.  
  89. if Chest == 3 then
  90.    print ("Done!")
  91. end
  92.  
  93. if Chest == 1 then
  94.    for i = 1, 16 do
  95.       turtle.select(i)
  96.       turtle.drop()  
  97.    end
  98. end
  99.  
  100.  
  101. if Chest == 2 then
  102.    turtle.select(16)
  103.    turtle.place()
  104.    sleep (1)
  105.    
  106.    for i = 1, 16 do
  107.       turtle.select(i)
  108.       turtle.drop()  
  109.    end
  110. end
  111.  
  112. turtle.turnLeft()
  113. turtle.turnLeft()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement