Advertisement
DustinRosebery

turtle_platform1.12

May 25th, 2016
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. left = true
  2. slot = 1
  3. width = 0
  4. depth = 0
  5. restart = "testPlatform" -- name of program for reseting
  6.  
  7.  
  8.  
  9.  
  10. -- Checks for Empty slot and switches if empty
  11.  
  12. local function slotCheck()
  13. if turtle.getItemCount() == 0 then
  14. slot = slot + 1
  15. end
  16. turtle.select(slot)
  17. end
  18.  
  19.  
  20.  
  21.  
  22. -- checks for material and fuel
  23.  
  24. local function matCheck()
  25.  
  26. material = 0
  27.  
  28. for i = 1, 16 do
  29. turtle.select(i)
  30. material = material + turtle.getItemCount()
  31. end
  32.  
  33. fuel = turtle.getFuelLevel()
  34. materialRequired = width * depth
  35.  
  36. if materialRequired > material then
  37. print("Not enough material to complete task")
  38. shell.run(restart)
  39. elseif materialRequired > fuel then
  40. print("Not enough fuel to complete task")
  41. shell.run(restart)
  42. else
  43. print("Materials and fuel are sufficient, starting platform")
  44. end
  45.  
  46. end
  47.  
  48.  
  49.  
  50.  
  51. -- Startup prompt
  52.  
  53. print("Platform dimensions, Width to the left and depth straight ahead.")
  54. print("Enter a width")
  55. width = read()
  56. print("Enter a depth")
  57. depth = read()
  58. matCheck()
  59.  
  60. -- Start of turtle movement
  61.  
  62. turtle.select(1)
  63. for i = 1, width do
  64.  
  65. for j = 1, depth do
  66. slotCheck()
  67. turtle.placeDown()
  68. turtle.forward()
  69. end
  70.  
  71. if left == true then
  72. turtle.turnLeft()
  73. turtle.forward()
  74. turtle.turnLeft()
  75. turtle.forward()
  76. left = false
  77. else
  78. turtle.turnRight()
  79. turtle.forward()
  80. turtle.turnRight()
  81. turtle.forward()
  82. left = true
  83. end
  84.  
  85. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement