Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. --[[
  2. By: skylarsch
  3. Usage: room <length (9)> <width (9)> <height (5)>
  4. Each of the arguments are optional, but if you must specify all the values before the one you want to change.
  5. --]]
  6.  
  7. -- MARK: Helper Functions
  8. function fwd() -- Move forward
  9. while not turtle.forward() do
  10. turtle.dig()
  11. end
  12. end
  13. function move(ammount) -- Move forward by the number of blocks
  14. for i = 0, ammount, 1 do
  15. fwd()
  16. end
  17. end
  18. function refuel() -- Refuel the turtle if it needs it
  19. local slot = 1
  20. while turtle.getFuelLevel() < 50 do
  21. if slot > 16 then
  22. print("Failed to refuel turtle")
  23. turtle.select(1)
  24. return false
  25. end
  26. turtle.select(slot)
  27. if not turtle.refuel(1) then
  28. slot = slot + 1
  29. end
  30. end
  31. turtle.select(1)
  32. return true
  33. end
  34. function up()
  35. while not turtle.up() do
  36. turtle.digUp()
  37. end
  38. end
  39. function down()
  40. while not turtle.down() do
  41. turtle.digDown()
  42. end
  43. end
  44. function goDown(ammount)
  45. for i = 0, ammount, 1 do
  46. down()
  47. end
  48. end
  49. function makeFloor(l, w)
  50. for i = 0, w + 1, 1 do
  51. move(l)
  52. if (i % 2 == 0) then
  53. if i <= w then
  54. turtle.turnRight()
  55. fwd()
  56. turtle.turnRight()
  57. else
  58. turtle.turnLeft()
  59. move(w)
  60. turtle.turnLeft()
  61. move(l)
  62. turtle.turnLeft()
  63. turtle.turnLeft()
  64. end
  65. else
  66. if i <= w then
  67. turtle.turnLeft()
  68. fwd()
  69. turtle.turnLeft()
  70. else
  71. turtle.turnRight()
  72. move(w)
  73. turtle.turnRight()
  74. end
  75. end
  76. refuel()
  77. end
  78. end
  79.  
  80. -- MARK: Main App
  81. local argv = {...}
  82. local length = (argv[1] or 54) - 2
  83. local width = (argv[2] or 35) - 2
  84. local height = (argv[3] or 4) - 1
  85.  
  86. print("Creating Room:")
  87. print(" "..(length + 2).."x"..(width + 2).."x"..(height + 1))
  88.  
  89. if not refuel() then
  90. print("Aborting...")
  91. return
  92. end
  93.  
  94. for floor = 0, height, 1 do
  95. makeFloor(length, width)
  96. if floor < height then
  97. up()
  98. else
  99. goDown(height - 1)
  100. end
  101. if not refuel() then
  102. print("Aborting...")
  103. return
  104. end
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement