Advertisement
vxste

ComputerCraft

Oct 8th, 2024 (edited)
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 KB | None | 0 0
  1. local function turnLeft(Times)
  2. Times = Times or 1
  3. for i = 1, Times do
  4. turtle.turnLeft()
  5. end
  6. end
  7.  
  8. local function turnRight(Times)
  9. Times = Times or 1
  10. for i = 1, Times do
  11. turtle.turnRight()
  12. end
  13. end
  14.  
  15. local function turnAround()
  16. turnRight(2)
  17. end
  18.  
  19. local function IsLava()
  20. local _, Data = turtle.inspect()
  21.  
  22. return Data.name == "minecraft:lava"
  23. end
  24.  
  25. local function SendMessage(Message)
  26. local WebhookURL = "https://discord.com/api/webhooks/1243847800190406696/LUlW18jdivKSnI63NeBwddMxbqFU_qtPvAON19nWLlFpjv5TFNvJqGcl19NH1fmwdALR"
  27. http.post(WebhookURL, '{"content": "' .. Message .. '"}', {["Content-Type"] = "application/json"})
  28. end
  29.  
  30. local function DigAndCollect(Side)
  31. Side = not Side and "f" or string.lower(Side)
  32. if Side == "f" then
  33. turtle.dig()
  34. elseif Side == "l" then
  35. turnLeft()
  36. turtle.dig()
  37. for i = 1, 4 do turnLeft() end
  38. elseif Side == "r" then
  39. turnRight()
  40. turtle.dig()
  41. turnLeft()
  42. elseif Side == "b" then
  43. turnLeft(2)
  44. turtle.dig()
  45. turnLeft(2)
  46. elseif Side == "u" then
  47. turtle.digUp()
  48. turtle.suckUp()
  49. return;
  50. elseif Side == "d" then
  51. turtle.digDown()
  52. turtle.suckDown()
  53. return;
  54. end
  55. turtle.suck()
  56. end
  57.  
  58. while true do
  59. if turtle.detectUp() then
  60. DigAndCollect("u")
  61. end
  62. if turtle.detect() then
  63. DigAndCollect("f")
  64. end
  65. turtle.forward()
  66. if not turtle.detectDown() then
  67. pcall(turtle.placeDown)
  68. end
  69. if IsLava() then
  70. SendMessage("@everyone Came across lava!!")
  71. turtle.place()
  72. turnAround()
  73. if not turtle.detect() then
  74. turtle.forward()
  75. turnRight()
  76. end
  77. end
  78. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement