Advertisement
HarvDad

pop

Jun 23rd, 2014
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1.  
  2. version = "pop: Rev 0.1"
  3. mission= "Protect Our Portal"
  4. instructions = "Place stack(s) of material starting in first slot."
  5.  
  6. args = {...}
  7. nArgs = #args
  8.  
  9. usage = "pop"
  10.  
  11. materialSlot = 1
  12.  
  13. length = 8
  14. width = 6
  15.  
  16. function place()
  17. ensureMaterial()
  18. turtle.place()
  19. end
  20.  
  21. function placeUp()
  22. ensureMaterial()
  23. turtle.placeUp()
  24. end
  25.  
  26. function placeDown()
  27. ensureMaterial()
  28. turtle.placeDown()
  29. end
  30.  
  31. function ensureMaterial()
  32. if turtle.getItemCount(materialSlot) < 3 then
  33. organizeMaterial()
  34. end
  35. if turtle.getItemCount(materialSlot) < 3 then
  36. print("No more material")
  37. return false
  38. end
  39. return true
  40. end
  41.  
  42. function organizeMaterial()
  43. local i
  44. materialCount = turtle.getItemCount(materialSlot)
  45.  
  46. if materialCount < 6 then
  47. -- print("Attempting to refill slot ", materialSlot)
  48. for i=2,12 do
  49. turtle.select(i)
  50. if turtle.compareTo(materialSlot) then
  51. turtle.transferTo(materialSlot)
  52. end
  53. end
  54. end
  55. turtle.select(materialSlot)
  56. end
  57.  
  58. function buildWall(length)
  59. for i=1,length do
  60. ensureMaterial()
  61. turtle.select(materialSlot)
  62. placeUp()
  63. placeDown()
  64. if i == length then
  65. turtle.turnLeft()
  66. end
  67. turtle.back()
  68. place()
  69. end
  70. end
  71.  
  72. turtle.forward()
  73. turtle.turnRight()
  74. turtle.up()
  75. buildWall(length)
  76. buildWall(width-1)
  77. buildWall(length-1)
  78. turtle.down()
  79. turtle.turnLeft()
  80. turtle.turnLeft()
  81. shell.run("floor 4 7 4")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement