Advertisement
Guest User

Untitled

a guest
Jun 19th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.01 KB | None | 0 0
  1. local component = require("component")
  2. local compuer = require("computer")
  3. local robot = require("robot")
  4. local shell = require("shell")
  5. local sides = require("sides")
  6. turn=1
  7.  
  8. local args, options = shell.parse(...)
  9. if #args < 1 then
  10. io.write("Useage: living <stacks>\n")
  11. return
  12. end
  13.  
  14. local size = tonumber(args[1])
  15. if not size then
  16. io.stderr:write("invalid stack amount")
  17. return
  18. end
  19.  
  20. local function swingFree()
  21. local tmp = robot.detect()
  22. while tmp == true do
  23. robot.swing()
  24. tmp = robot.detect()
  25. end
  26. end
  27.  
  28. local function swingFreeDown()
  29. local tmp = robot.detectDown()
  30. while tmp == true do
  31. robot.swingDown()
  32. tmp = robot.detectDown()
  33. end
  34. robot.placeDown() --place new stone
  35. end
  36.  
  37. --BLOCK OF WALK
  38. for i=1, size*2 do --movement
  39. robot.select(1)
  40. robot.dropDown() --remove half stack
  41. robot.suckDown() --get full stone stack
  42. swingFree()
  43. robot.forward()
  44. for j=1, 6 do --lines
  45. for k=1, 5 do --blocks
  46. if j==1 or j==3 or j==4 or j==6 then --dig full lines
  47. swingFreeDown()
  48. swingFree() --prevent mob corruption
  49. robot.forward()
  50. else --do not dig flowers
  51. if k==1 or k==3 or k==4 or k==6 then
  52. swingFreeDown()
  53. swingFree()
  54. robot.forward()
  55. else
  56. swingFree()
  57. robot.forward()
  58. end
  59. end
  60. end --blocks
  61. if j<6 then --do not turn on last line
  62. if (turn==1) then --goto next line right
  63. swingFreeDown()
  64. robot.turnRight()
  65. swingFree() --prevent mob corruption
  66. robot.forward()
  67. robot.turnRight()
  68. else --goto next line left
  69. swingFreeDown()
  70. robot.turnLeft()
  71. swingFree() --prevent mob corruption
  72. robot.forward()
  73. robot.turnLeft()
  74. end
  75. end
  76. if turn==1 then turn=2 else turn=1 end
  77. end --lines
  78. swingFreeDown()
  79. robot.forward()
  80. robot.select(2)
  81. robot.dropDown() --remove living BLOCK
  82. robot.select(1)
  83. robot.turnRight()
  84. for a=1, 5 do swingFree() robot.forward() end
  85. robot.turnRight()
  86. os.sleep(15)
  87. end --movement
  88. print("finished")
  89. os.execute("shutdown")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement