zurbo

cc_tunnel1.0

Dec 23rd, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.34 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 line(side,lenght)
  29. -- side est un nombre : 0 vers la droite, 1 vers la gauche
  30.     if side == 0 then
  31.         turtle.turnRight()
  32.         moving(lenght)
  33.         turtle.turnLeft()
  34.     else
  35.         turtle.turnLeft()
  36.         moving(lenght)
  37.         turtle.turnRight()
  38.     end
  39. end
  40.  
  41. function tunneling(lenght)
  42.     i=0
  43.     while i<lenght do
  44.         line(i%2,lenght)
  45.         stepUp()
  46.         i=i+1
  47.     end
  48.    
  49.     line(i%2,lenght)
  50.    
  51.     if i%2 == 0 then
  52.         line(1,lenght)
  53.     end
  54.    
  55.     i=0
  56.    
  57.     while i<lenght do
  58.         stepDown()
  59.         i=i+1
  60.     end
  61.     step()     
  62. end
  63.  
  64. function pose()
  65.     turtle.select(1)
  66.     turtle.place()
  67.     i=2
  68.     while i<16 do
  69.         i=i+1
  70.         turtle.select(i)
  71.         turtle.drop()
  72.     end
  73.     turtle.select(1)
  74.     turtle.dig()
  75. end
  76.  
  77. function refueling()
  78.     turtle.select(2)
  79.     turtle.place()
  80.     turtle.select(3)
  81.     turtle.suck()
  82.     turtle.refuel(6)
  83.     turtle.select(2)
  84.     turtle.dig()
  85.    
  86. end
  87.  
  88. while 1 do
  89.     tunneling(19)
  90.     turtle.turnLeft()
  91.     turtle.turnLeft()
  92.     pose()
  93.     while turtle.getFuelLevel()<400 do
  94.         refueling()
  95.     end
  96.     turtle.turnLeft()
  97.     turtle.turnLeft()
  98. end
Advertisement
Add Comment
Please, Sign In to add comment