Advertisement
theradman221

mining semi advanced with variables?

Sep 18th, 2019
160
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. turtle.select(2)
  2. turtle.refuel()
  3. local a = 0
  4. -- a is for comparing length, b is for width, and c is determining right or left at the end, default is turn right at first --and switch.
  5. local b = 0
  6. local c = 0
  7. local length = 60
  8. local width = 60
  9. local miners = 0
  10. local height = 0
  11. local fuellevel = turtle.getFuelLevel()
  12.  
  13. --check for file to save variables to
  14. if not fs.exists("Adata", "w") then
  15.   local file = io.open("Adata", "w")
  16.   file:write()
  17.   file:close()
  18. end
  19.  
  20. if not fs.exists("Bdata", "w") then
  21.   local file = io.open("Bdata", "w")
  22.   file:write()
  23.   file:close()
  24. end
  25.  
  26. if not fs.exists("Cdata", "w") then
  27.   local file = io.open("Cdata", "w")
  28.   file:write()
  29.   file:close()
  30. end
  31.  
  32. local function saveDataA()
  33.  local file = io.open("Adata", "w')
  34. file:write(a)
  35. file:close()
  36. end
  37.  
  38.  
  39. local function saveDataB()
  40. local file = io.open("Bdata", "w')
  41. file:write(b)
  42. file:close()
  43. end
  44.  
  45. local function saveDataC()
  46. local file = io.open("Cdata", "w')
  47.  file:write(c)
  48.  file:close()
  49. end
  50.  
  51. local file = io.open("Adata", "r") --open in read mode
  52. a = file:read()
  53. file:close()
  54.  
  55. local file = io.open("Bdata", "r") --open in read mode
  56. b = file:read()
  57. file:close()
  58.  
  59. local file = io.open("Cdata", "r") --open in read mode
  60. c = file:read()
  61. file:close()
  62.  
  63. repeat
  64. repeat
  65.   turtle.dig()
  66.   if turtle.detect() == true then
  67.   repeat   
  68.   turtle.dig()
  69.   until turtle.detect() == false
  70.   end
  71.   turtle.forward()
  72.   turtle.digDown()
  73.   a = a + 1
  74.   saveDataA()
  75.   if turtle.getItemCount(16) ~= 0 then
  76.   turtle.select(1)
  77.   turtle.back()
  78.   turtle.down()
  79.   turtle.place()
  80.   for i = 2,16 do
  81.     turtle.select(i)
  82.     turtle.drop()
  83.   end
  84.     turtle.up()
  85.     turtle.forward()
  86.     turtle.select(2)
  87.   end
  88.   until a == length
  89.  
  90.     a = 0
  91.     if ( c == 0 ) then
  92.       turtle.turnRight()
  93.       turtle.dig()
  94.       if turtle.detect() == true then
  95.          repeat  
  96.          turtle.dig()
  97.          until turtle.detect() == false
  98.       end
  99.       turtle.forward()
  100.       turtle.digDown()
  101.       turtle.turnRight()
  102.       b = b + 1
  103.       saveDataB()
  104.     end
  105.     if ( c == 1 ) then
  106.       turtle.turnLeft()
  107.       turtle.dig()
  108.       if turtle.detect() == true then
  109.         repeat  
  110.         turtle.dig()
  111.         until turtle.detect() == false
  112.       end
  113.       turtle.forward()
  114.       turtle.digDown()
  115.       turtle.turnLeft()
  116.       b = b + 1
  117.     end
  118.     if ( c == 1) then
  119.       c = 0
  120.       saveDataC()
  121.     elseif ( c == 0) then
  122.       c = 1
  123.       saveDataC()
  124.     else
  125.     end
  126.     turtle.refuel()
  127.     fuellevel = turtle.getFuelLevel()
  128.     print("number of runs "..b)
  129.     print("fuel level " ..fuellevel)
  130.     until b == width
  131. a = 0
  132. b = 0
  133. c = 0
  134. saveDataA()
  135. saveDataB()
  136. saveDataC()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement