zurbo

cc_tunnel2.0

Dec 24th, 2013
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.56 KB | None | 0 0
  1. function step()
  2.     turtle.dig()
  3.     turtle.attack()
  4.     return(turtle.forward())
  5. end
  6.  
  7. function stepDown()
  8.     turtle.digDown()
  9.     turtle.attackDown()
  10.     return(turtle.down())
  11. end
  12.  
  13. function stepUp()
  14.     turtle.digUp()
  15.     turtle.attackUp()
  16.     return(turtle.up())
  17. end
  18.  
  19. function moving(lenght)
  20.     local i = 0
  21.     while i<lenght do
  22.         if step() then
  23.             i = i+1
  24.         end
  25.     end
  26. end
  27.  
  28. function movingUp(lenght)
  29.     local i = 0
  30.     while i<lenght do
  31.         if stepUp() then
  32.             i = i+1
  33.         end
  34.     end
  35. end
  36.  
  37. function movingDown(lenght)
  38.     local i = 0
  39.     while i<lenght do
  40.         if stepDown() then
  41.             i = i+1
  42.         end
  43.     end
  44. end
  45.  
  46. function line(side,lenght)
  47. -- side est un nombre : 0 vers la droite, 1 vers la gauche
  48.     if side == 0 then
  49.         turtle.turnRight()
  50.         moving(lenght)
  51.         turtle.turnLeft()
  52.     else
  53.         turtle.turnLeft()
  54.         moving(lenght)
  55.         turtle.turnRight()
  56.     end
  57. end
  58.  
  59. function tunneling(lenght)
  60.     local i=0
  61.     while i<lenght do
  62.         line(i%2,lenght)
  63.         movingUp(1)
  64.         i=i+1
  65.     end
  66.    
  67.     line(i%2,lenght)
  68.    
  69.     if i%2 == 0 then
  70.         line(1,lenght)
  71.     end
  72.     movingDown(lenght)
  73.     moving(1)      
  74. end
  75.  
  76. function pose()
  77.     turtle.select(1)
  78.     turtle.place()
  79.     local i=2
  80.     while i<16 do
  81.         i=i+1
  82.         turtle.select(i)
  83.         turtle.drop()
  84.     end
  85.     turtle.select(1)
  86.     turtle.dig()
  87. end
  88.  
  89. function refueling()
  90.     turtle.select(2)
  91.     turtle.place()
  92.     turtle.select(3)
  93.     turtle.suck()
  94.     turtle.refuel(turtle.getItemCount(3))
  95.     turtle.select(2)
  96.     turtle.dig()
  97.    
  98. end
  99.  
  100. while 1 do
  101.     tunneling(19)
  102.     turtle.turnLeft()
  103.     turtle.turnLeft()
  104.     pose()
  105.     while turtle.getFuelLevel()<450 do
  106.         refueling()
  107.     end
  108.     turtle.turnLeft()
  109.     turtle.turnLeft()
  110. end
Advertisement
Add Comment
Please, Sign In to add comment