drexplosionpd

createRoom

May 23rd, 2020 (edited)
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.25 KB | None | 0 0
  1. os.loadAPI("homeAPI")
  2.  
  3. local tArgs = {...}
  4. if #tArgs ~= 3 then
  5. print("Usage: room <length> <width> <height>")
  6. return
  7. end
  8. height = tonumber(tArgs[3])
  9. width = tonumber(tArgs[2])
  10. length = tonumber(tArgs[1])
  11.  
  12. if turtle.getFuelLevel() < (height * width * length) then
  13. print("not enough fuel to complete room")
  14. return
  15. end
  16.  
  17. function breakBlock()
  18. while turtle.detect() do
  19. turtle.dig()
  20. sleep(0.4)
  21. end
  22. end
  23.  
  24. function turn(bool)
  25. if bool then
  26. homeAPI.turnRight()
  27. breakBlock()
  28. homeAPI.forward()
  29. homeAPI.turnRight()
  30. return not bool
  31. else
  32. homeAPI.turnLeft()
  33. breakBlock()
  34. homeAPI.forward()
  35. homeAPI.turnLeft()
  36. return not bool
  37. end
  38. end
  39.  
  40. bool = true
  41.  
  42. for h = 1, height do
  43. for w = 1, width do
  44. for l = 2, length do
  45. homeAPI.invState()
  46. breakBlock()
  47. homeAPI.forward()
  48. end
  49.  
  50. if w ~= width then
  51. bool = turn(bool)
  52. else
  53. homeAPI.turnLeft()
  54. homeAPI.turnLeft()
  55. end
  56. end
  57. if(h ~= height) then
  58. while turtle.detectUp() do
  59. turtle.digUp()
  60. sleep(0.4)
  61. end
  62. homeAPI.up()
  63. end
  64. end
Add Comment
Please, Sign In to add comment