Advertisement
Guest User

Untitled

a guest
Feb 6th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.24 KB | None | 0 0
  1. function clear()
  2.     term.clear()
  3.     term.setCursorPos(1,1)
  4. end
  5.  
  6. function stopProgram()
  7.     print("(Hold Ctrl+T to end program.)")
  8. end  
  9.  
  10. function askLWD()
  11.     print("Enter numerical values that are greater than one for the following.")
  12.     write("Lenght: ") L = tonumber(read())
  13.     write("Width : ") W = tonumber(read())
  14.     write("Depth : ") D = tonumber(read())
  15. end
  16.  
  17. function digDepth()
  18.     if width % 2 == 0 then
  19.         while turtle.detectUp() do
  20.             turtle.digUp()
  21.             os.sleep(.5)
  22.         end
  23.         if depth ~= D then
  24.             turtle.up()
  25.         else
  26.         end
  27.     else
  28.         while turtle.detectDown() do
  29.             turtle.digDown()
  30.         end
  31.         if depth ~= D then
  32.         turtle.down()
  33.         else
  34.         end
  35.     end
  36. end
  37.  
  38. function digRight()
  39.     if width ~= W then
  40.         turtle.turnRight()
  41.         while turtle.detect() do
  42.             turtle.dig()
  43.             os.sleep(.5)
  44.         end
  45.         turtle.forward()
  46.         turtle.turnLeft()
  47.     else
  48.         while turtle.detect() do
  49.             turtle.dig()
  50.             os.sleep(.5)
  51.         end
  52.         turtle.forward()
  53.     end
  54. end
  55.  
  56. function digLeft()
  57.     if width ~= W then
  58.         turtle.turnLeft()
  59.         while turtle.detect() do
  60.             turtle.dig()
  61.             os.sleep(.5)
  62.         end
  63.         turtle.forward()
  64.         turtle.turnRight()
  65.     else
  66.         while turtle.detect() do
  67.             turtle.dig()
  68.             os.sleep(.5)
  69.         end
  70.         turtle.forward()
  71.     end
  72. end
  73.  
  74. clear()
  75. stopProgram()
  76. print("Place the turtle 'IN THE BLOCK' that is top left corner of the room facing the direction that will be the lenght of the room.")
  77. print("Press enter to continue...")
  78. read()
  79. clear()
  80. stopProgram()
  81. askLWD()
  82. while type(L) ~= "number" or type(W) ~= "number" or type(D) ~= "number" do
  83.     clear()
  84.     stopProgram()
  85.     print("Error... You must enter a valid number greater than zero for all 3 values.")
  86.     askLWD()
  87. end
  88. print("The room will be "..L.." in lenght,"..W.." in width &"..D.."in depth.")
  89. print("Press enter to begin creating room.")
  90. stopProgram()
  91. read()
  92.  
  93. for lenght = 1, L do
  94.     for width = 1, W do
  95.         for depth = 1, D-1 do
  96.             digDepth()  
  97.         end
  98.         if lenght % 2 == 0 then
  99.             digLeft()
  100.         else
  101.             digRight()
  102.         end
  103.     end
  104. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement