Advertisement
Guest User

cMining

a guest
Sep 23rd, 2014
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.23 KB | None | 0 0
  1. local a = 1
  2. local b = 0
  3. local thisID = os.getComputerID()
  4.  
  5. local function gravelDetect()
  6.     turtle.select(1)
  7.     if turtle.compare() == true then
  8.         repeat
  9.             turtle.dig()
  10.         until turtle.compare() == false
  11.         repeat
  12.             turtle.digUp()
  13.         until turtle.compareUp() == false
  14.     end
  15. end
  16.  
  17. local function gravelDetectUp()
  18.     turtle.select(1)
  19.     if turtle.compareUp() == true then
  20.         repeat
  21.             turtle.digUp()
  22.             sleep(0.5)
  23.         until turtle.compareUp() == false
  24.     end
  25. end
  26.  
  27. local function oneMove()
  28.     turtle.dig()
  29.     gravelDetect()
  30.     turtle.forward()
  31.     --[[b = b+1
  32.     print("Sending2 to "..thisID + 1)
  33.     rednet.send(thisID+1,"+1")
  34.     repeat --Attend la råA5A9ponse du placeur
  35.         local id, clStatus = rednet.receive()
  36.     until clStatus == "done" ]]--
  37.     turtle.digUp()
  38.     gravelDetectUp()
  39. end
  40.  
  41. local function tunnel() --CråA5A9e le tunnel de 7 blocs
  42.     for i=1,7 do --Creuse 7 de profond
  43.         oneMove()
  44.     end
  45.     turtle.turnLeft()
  46.     turtle.turnLeft()
  47.     for i=1,7 do --Revient sur ses pas
  48.         turtle.forward()
  49.     end
  50. end
  51.  
  52. local function placeTorch() --Se retourne pour placer une torche
  53.    turtle.select(15)
  54.    turtle.turnLeft()
  55.    turtle.turnLeft()
  56.    turtle.place()
  57. end
  58.  
  59. local function chunkLoaderPlacer() --Place un spot loader åA5A0 chaque fois qu'il avance de 1 chunk
  60.     local clStatus = nil
  61.     if b == 1 then --VåA5A9rifie s'il se trouve sur une nouvelle chunk
  62.         print("Sending to "..thisID+1)
  63.         rednet.send(thisID+1,"chunk+1")
  64.         repeat --Attend la råA5A9ponse du placeur
  65.             local id, clStatus = rednet.receive()
  66.         until clStatus == "done"
  67.     elseif b == 16 then
  68.         b = 0
  69.     end
  70. end
  71.  
  72. local function torchMaintain()
  73.     turtle.select(15)
  74.     if turtle.getItemCount() == 0 then
  75.         turtle.turnLeft()
  76.         turtle.turnLeft()
  77.         for i=1,96*a do
  78.             turtle.forward()
  79.         end
  80.         turtle.select(16)
  81.         turtle.suck()
  82.         turtle.select(15)
  83.         turtle.turnRight()
  84.         turtle.suck()
  85.         turtle.turnRight()
  86.         for i=1,96*a do
  87.             turtle.forward()
  88.         end
  89.         a = a+1
  90.     end
  91. end
  92.  
  93.  
  94.  
  95. --rednet.open("left")
  96.  
  97. turtle.select(16)
  98. turtle.suckUp()
  99. turtle.refuel()
  100. turtle.turnLeft()
  101. turtle.select(15)
  102. turtle.suck()
  103. turtle.turnRight()
  104.  
  105. while true do
  106.  
  107.     oneMove()
  108.     --chunkLoaderPlacer()
  109.    
  110.     turtle.turnRight()
  111.     turtle.dig()
  112.     gravelDetect()
  113.     turtle.forward()
  114.     turtle.digUp()
  115.     gravelDetectUp()
  116.     turtle.turnLeft()
  117.    
  118.     oneMove()
  119.     --chunkLoaderPlacer()
  120.    
  121.     turtle.turnLeft()
  122.     turtle.dig()
  123.     gravelDetect()
  124.     turtle.forward()
  125.     turtle.digUp()
  126.     gravelDetectUp()
  127.     turtle.turnRight()
  128.    
  129.     oneMove()
  130.     --chunkLoaderPlacer()
  131.    
  132.     turtle.turnLeft()
  133.  
  134.     tunnel()
  135.     placeTorch()
  136.     turtle.turnRight()
  137.     --torchMaintain()
  138.     turtle.turnRight()
  139.  
  140.     turtle.dig()
  141.     gravelDetect()
  142.     turtle.forward()
  143.     turtle.digUp()
  144.     gravelDetectUp()
  145.  
  146.     tunnel()
  147.     placeTorch()
  148.  
  149.     turtle.turnLeft()
  150.     turtle.turnLeft()
  151.     gravelDetect()
  152.     turtle.forward()
  153.     turtle.turnRight()
  154.     --torchMaintain()
  155. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement