Advertisement
NAPTlME

Ceiling

Jan 13th, 2014
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.82 KB | None | 0 0
  1. --Ceiling
  2. --NAPTlME
  3.  
  4. --Main
  5. function ceiling()
  6.   term.write("How many blocks forward?\n")
  7.   local length = tonumber(read())
  8.   term.write("How many blocks to the right?\n")
  9.   local width = tonumber(read())
  10.   term.write("How many blocks up?\n")
  11.   local height = tonumber(read())
  12.   term.write("Now raising the roof.")
  13.   sleep(1)
  14.   turtle.turnRight()
  15.   digCeiling(length, width, height)
  16. end
  17.  
  18. --Dig
  19. function digCeiling(length, width, height)
  20.   for i =1,height do
  21.     for j = 1,length do
  22.       local u = 1
  23.       for k = 1,width do
  24.         turtle.digUp()
  25.         if u < width then
  26.           turtle.forward()
  27.           u = u+1
  28.         end
  29.       end
  30.       if length == j then
  31.         print("Ready for next row")
  32.       elseif isOdd(j) then
  33.         turtle.turnLeft()
  34.         turtle.forward()
  35.         turtle.turnLeft()
  36.       else
  37.         turtle.turnRight()
  38.         turtle.forward()
  39.         turtle.turnRight()
  40.       end
  41.     end
  42.     if i == height then
  43.       print("Thank you for choosing...\n RestEasy:\n SecureSolutions")
  44.       repeat
  45.         turtle.down()
  46.       until turtle.detectDown() == true
  47.       for b = 1,3 do
  48.        turtle.up()
  49.       end
  50.     elseif isOdd(length) then
  51.       turtle.turnRight()
  52.       local l = 1
  53.       while l < length do
  54.         turtle.forward()
  55.         l = l + 1
  56.       end
  57.       turtle.turnRight()
  58.       local l=1
  59.       while l < width do
  60.         turtle.forward()
  61.         l = l+1
  62.       end
  63.       turtle.turnRight()
  64.       turtle.turnRight()
  65.       turtle.up()
  66.     else
  67.       turtle.turnLeft()
  68.       local l = 1
  69.       while l < length do
  70.         turtle.forward()
  71.         l = l+1
  72.       end
  73.       turtle.turnLeft()
  74.       turtle.up()
  75.     end
  76.   end
  77. end
  78.  
  79. --Is the number odd?
  80. function isOdd(n)
  81.   if n%2 == 1 then
  82.     return true
  83.   else
  84.     return false
  85.   end
  86. end
  87.  
  88. ceiling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement