Guest User

room

a guest
Nov 6th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.92 KB | None | 0 0
  1. function refuel()
  2.   if turtle.getFuelLevel()==0 then
  3.     a = turtle.getSelectedSlot()
  4.     turtle.select(16)
  5.     while turtle.refuel(5)==false do
  6.       term.write("Please refuel me!!")
  7.       sleep(1)
  8.       term.clear()
  9.       term.setCursorPos(1, 1)
  10.     end
  11.     turtle.select(a)
  12.   end
  13. end
  14.  
  15. function forward()
  16.   while turtle.forward()==false do
  17.     turtle.dig()
  18.     refuel()
  19.   end
  20. end
  21.  
  22. function up()
  23.   while turtle.up()==false do
  24.     turtle.digUp()
  25.     refuel()
  26.   end
  27. end
  28.  
  29. function down()
  30.   while turtle.down()==false do
  31.     turtle.digDown()
  32.     refuel()
  33.   end
  34. end
  35.  
  36. function around()
  37.   turtle.turnLeft()
  38.   turtle.turnLeft()
  39. end
  40.  
  41. function selection()
  42.   for i = 1, 14 do
  43.     turtle.select(i)
  44.     if turtle.compareTo(15)==true then
  45.       break
  46.     end
  47.     if i==14 then
  48.       while turtle.compareTo(15)==false do
  49.         turtle.select(1)
  50.         print("Please give me some more blocks")
  51.         sleep(1)
  52.         term.clear()
  53.         term.setCursorPos(1, 1)
  54.       end
  55.     end
  56.   end
  57. end
  58.  
  59. function dig()
  60.   while turtle.detect()==true do
  61.     turtle.dig()
  62.   end
  63. end
  64.  
  65. --Main program
  66.  
  67. term.clear()
  68. term.setCursorPos(1, 1)
  69. term.write("How wide should the room be ? ")
  70. y = read()
  71. print(y)
  72. term.write("How deep should the room be? ")
  73. d = read()
  74. term.write("How high should the room be ? ")
  75. c = read()
  76. x = d-1
  77. z = c-1
  78.  
  79. term.clear()
  80. term.setCursorPos(1, 1)
  81. print("Work in progress..")
  82. for k= 1, y do
  83.   for j= 1, z do
  84.     for i= 1, x do
  85.       print(y)
  86.       if j==1 then
  87.         selection()
  88.         turtle.digDown()
  89.         turtle.placeDown()
  90.       end
  91.       if j==z then
  92.         while turtle.detectUp()==true do
  93.           turtle.digUp()
  94.         end
  95.         selection()
  96.         turtle.placeUp()
  97.       end
  98.       if i==1 then
  99.         around()
  100.         dig()
  101.         selection()
  102.         turtle.place()
  103.         around()
  104.       end
  105.       if k==1 then
  106.         if j%2==0 then
  107.           turtle.turnRight()
  108.           dig()
  109.           selection()
  110.           turtle.place()
  111.           turtle.turnLeft()
  112.         else
  113.           turtle.turnLeft()
  114.           dig()
  115.           selection()
  116.           turtle.place()
  117.           turtle.turnRight()
  118.         end
  119.       end
  120.       if k==y then
  121.         if j%2==0 then
  122.           turtle.turnLeft()
  123.           dig()
  124.           selection()
  125.           turtle.place()
  126.           turtle.turnRight()
  127.         else
  128.           turtle.turnRight()
  129.           dig()
  130.           selection()
  131.           turtle.place()
  132.           turtle.turnLeft()
  133.         end
  134.       end
  135.       forward()
  136.       if i==x then
  137.         if k==1 then
  138.           if j%2==0 then
  139.             turtle.turnRight()
  140.             dig()
  141.             selection()
  142.             turtle.place()
  143.             turtle.turnLeft()
  144.           else
  145.             turtle.turnLeft()
  146.             dig()
  147.             selection()
  148.             turtle.place()
  149.             turtle.turnRight()
  150.           end
  151.         end
  152.         if k==y then
  153.           if j%2==0 then
  154.             turtle.turnLeft()
  155.             dig()
  156.             selection()
  157.             turtle.place()
  158.             turtle.turnRight()
  159.           else
  160.             turtle.turnRight()
  161.             dig()
  162.             selection()
  163.             turtle.place()
  164.             turtle.turnLeft()
  165.           end
  166.         end
  167.         dig()
  168.         selection()
  169.         turtle.place()
  170.       end
  171.     end
  172.     if j==1 then
  173.       turtle.digDown()
  174.       selection()
  175.       turtle.placeDown()
  176.     end
  177.     up()
  178.     around()
  179.   end
  180.   for i = 1, x do
  181.   if i==1 then
  182.     around()
  183.     dig()
  184.     selection()
  185.     turtle.place()
  186.     around()
  187.   end
  188.     while turtle.detectUp()==true do
  189.       turtle.digUp()
  190.     end
  191.     selection()
  192.     turtle.placeUp()
  193.     if k==1 then
  194.       if c%2==0 then
  195.         turtle.turnRight()
  196.         selection()
  197.         dig()
  198.         turtle.place()
  199.         turtle.turnLeft()
  200.       else
  201.         turtle.turnLeft()
  202.         dig()
  203.         selection()
  204.         turtle.place()
  205.         turtle.turnRight()
  206.       end
  207.     end
  208.     forward()
  209.     if k==1 then
  210.       if i==x then
  211.         if c%2==0 then
  212.           turtle.turnRight()
  213.           dig()
  214.           selection()
  215.           turtle.place()
  216.           turtle.turnLeft()
  217.         else
  218.           turtle.turnLeft()
  219.           dig()
  220.           selection()
  221.           turtle.place()
  222.           turtle.turnRight()
  223.         end
  224.       end
  225.     end
  226.     if i==x then
  227.       dig()
  228.       selection()
  229.       turtle.place()
  230.     end
  231.   end
  232.   while turtle.detectUp()==true do
  233.     turtle.digUp()
  234.   end
  235.   selection()
  236.   turtle.placeUp()
  237.   if c%2==0 then
  238.     for i = 1, z do
  239.       down()
  240.     end
  241.     turtle.turnLeft()
  242.     forward()
  243.     turtle.turnLeft()
  244.   else
  245.     around()
  246.     for i = 1, x do
  247.       turtle.forward()
  248.     end
  249.     for i = 1, z do
  250.       down()
  251.     end
  252.     turtle.turnLeft()
  253.     if k ~= y then
  254.       forward()
  255.     end
  256.     turtle.turnLeft()
  257.   end
  258. end
  259. --term.clear()
  260. term.setCursorPos(1, 1)
  261. print("Work is done!")
Advertisement
Add Comment
Please, Sign In to add comment