Advertisement
pickar

a tortoroise digging parallelepipeds

May 30th, 2016
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. t=turtle
  2.  
  3. function detect()
  4.     while t.detect() do
  5.         t.dig()
  6.     end
  7.     while t.detectUp() do
  8.         t.digUp()
  9.     end
  10. end
  11.  
  12. function dig()
  13.     t.digUp()
  14.     t.dig()
  15.     t.digDown()
  16.     detect()
  17.     chest()
  18.     t.forward()
  19. end
  20.  
  21. function digger()
  22.     if p==1 then t.turnRight() else t.turnLeft() end
  23.     x=x-1
  24.     while x>0 do
  25.         x=x-1
  26.         dig()
  27.         chest()
  28.     end
  29.     y=y-1
  30.     x=ox
  31.     t.digUp()
  32.     t.digDown()
  33.     if y>0 then
  34.         if p==1 then t.turnLeft() else t.turnRight() end
  35.         dig()
  36.     else t.down()
  37.         t.digDown()
  38.         t.down()
  39.         t.digDown()
  40.         t.down()
  41.         y=oy
  42.         z=z-3
  43.         if p==0 then t.turnLeft() p=1 else t.turnRight() p=0 end
  44.     end
  45.    
  46.     if p==1 then p=0 else p=1 end
  47.     fuel()
  48. end
  49.  
  50. function drop()
  51.     t.select(16)
  52.     t.place()
  53.     for i=1,14 do
  54.         t.select(i)
  55.         t.drop()
  56.     end
  57.     t.select(1)
  58.     fuel()     
  59. end
  60.  
  61. function chest()
  62.     if t.getItemCount(14)>0 then
  63.         if p==1 then
  64.         t.turnRight()
  65.         drop()
  66.         t.turnLeft()
  67.         else
  68.         t.turnLeft()
  69.         drop()
  70.         t.turnRight()  
  71.         end
  72.     end
  73. end        
  74.  
  75.  
  76.  
  77. function clear()
  78.     term.clear()
  79.     term.setCursorPos(1,1)
  80. end
  81.  
  82. function fuel()
  83.     if t.getFuelLevel() < x*y then print("Refuel") t.select(15)
  84.         while t.getFuelLevel() < x*y do
  85.             t.refuel(1)
  86.         end
  87.     end
  88.     t.select(1)
  89. end
  90.  
  91.  
  92.  
  93. clear()
  94. print("Width")
  95. ox=read()
  96. ox=tonumber(ox)
  97. print("Length")
  98. oy=read()
  99. oy=tonumber(oy)
  100. print("Height ( multiple 3 )")
  101. z=read()
  102. z=tonumber(z)
  103. x=ox
  104. y=oy
  105. fuel()
  106. p=1
  107. while z>0   do
  108.     digger()
  109. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement