Xmann1

Untitled

Dec 23rd, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.08 KB | None | 0 0
  1. os.loadAPI("disk/json")
  2.  
  3. function refuel()
  4. if turtle.getFuelLevel() < 10 then
  5. for i=1, 16 do
  6. if turtle.refuel(1) then
  7. break
  8. end
  9. end
  10. end
  11. end
  12.  
  13. function soft_forward()
  14. while not turtle.forward() do
  15. a, b = turtle.inspect()
  16. if a then
  17. if string.sub(b.name, 0, 13) ~= "computercraft" then
  18. turtle.dig()
  19. end
  20. end
  21. end
  22. end
  23.  
  24. function soft_down()
  25. while not turtle.down() do
  26. a, b = turtle.inspectDown()
  27. if a then
  28. if string.sub(b.name, 0, 13) ~= "computercraft" then
  29. turtle.digDown()
  30. end
  31. end
  32. end
  33. end
  34.  
  35. function soft_up()
  36. while not turtle.up() do
  37. a, b = turtle.inspectUp()
  38. if a then
  39. if string.sub(b.name, 0, 13) ~= "computercraft" then
  40. turtle.digUp()
  41. end
  42. end
  43. end
  44. end
  45.  
  46.  
  47. function soft_dig_up()
  48. a, b = turtle.inspectUp()
  49. if a then
  50. if string.sub(b.name, 0, 13) ~= "computercraft" then
  51. turtle.digUp()
  52. end
  53. end
  54. end
  55.  
  56. function soft_dig_down()
  57. a, b = turtle.inspectDown()
  58. if a then
  59. if string.sub(b.name, 0, 13) ~= "computercraft" then
  60. turtle.digDown()
  61. end
  62. end
  63. end
  64.  
  65. ws, err = http.websocket("jogt.xyz:7777")
  66.  
  67. packet = json.decode(ws.receive())
  68.  
  69. while not turtle.suckUp(64) do sleep(1) end
  70. refuel()
  71.  
  72. turtle.forward()
  73.  
  74. for y=1, packet["y"] do
  75. refuel()
  76. soft_down()
  77. soft_down()
  78. end
  79.  
  80. for x=1, packet["x"] do
  81. refuel()
  82. soft_forward()
  83. soft_dig_up()
  84. soft_dig_down()
  85. soft_forward()
  86. soft_dig_up()
  87. soft_dig_down()
  88. end
  89.  
  90. if packet["x"] % 2 == 0 then
  91. soft_up()
  92. end
  93.  
  94. if packet["y"] % 2 == 0 then
  95. soft_forward()
  96. end
  97.  
  98. turtle.turnRight()
  99.  
  100. for i=1, 100 do
  101. refuel()
  102. soft_forward()
  103. turtle.digUp()
  104. turtle.digDown()
  105. turtle.turnRight()
  106. turtle.dig()
  107. turtle.turnLeft()
  108. turtle.turnLeft()
  109. turtle.dig()
  110. turtle.turnRight()
  111. end
  112.  
Advertisement
Add Comment
Please, Sign In to add comment