EdgeLordKirito

movement test

May 28th, 2023 (edited)
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. DISTANCETOHOMEBASE = 0
  2.  
  3.  
  4. function MoveDownwardByOne()
  5. if CheckRetreatParameters() or CheckForBedrockBeneath() then
  6. print("Critical Error")
  7. local x,y,z = gps.locate()
  8. SavedX = x
  9. SavedY = y
  10. SavedZ = z
  11. print("close To retreating")
  12. Retreat()
  13. end
  14. if turtle.getFuelLevel() < 20 then
  15. Refuel()
  16. end
  17. local existence = turtle.inspectDown()
  18. if existence then
  19. turtle.digDown()
  20. end
  21. turtle.down()
  22. end
  23.  
  24. function CheckRetreatParameters()
  25. local lowFuel = LowFuel()
  26. local fullInventory = InventoryHasfreeSpace()
  27. if lowFuel then
  28. print("Fuel")
  29. return true
  30. end
  31. if fullInventory then
  32. print("Inventory")
  33. return true
  34. end
  35. end
  36.  
  37. function CheckForBedrockBeneath()
  38. local success,data = turtle.inspectDown()
  39. if success then
  40. if data.name == "minecraft:bedrock" then
  41. return true
  42. else
  43. return false
  44. end
  45. else
  46. return false
  47. end
  48. end
  49.  
  50. function LowFuel()
  51. local extraSafetyDistance = 10
  52. if DISTANCETOHOMEBASE < CalculateTotalFuel() + extraSafetyDistance then
  53. return false
  54. else if DISTANCETOHOMEBASE >= CalculateTotalFuel() + extraSafetyDistance then
  55. return true
  56. end
  57. end
  58. end
  59.  
  60. function CalculateTotalFuel()
  61. local result = turtle.getFuelLevel() + turtle.getItemCount(1) * 80
  62. return result
  63. end
  64.  
  65.  
  66. function InventoryHasfreeSpace()
  67. local count = turtle.getItemCount(16)
  68. if count == 0 then
  69. return false
  70. else
  71. return true
  72. end
  73. end
  74.  
  75. function CalculateHomebaseDistance(baseX,BaseY,BaseZ)
  76. local x,y,z = gps.locate()
  77. local result = CalculateTotalDistance(CalculateDistance(baseX,x),CalculateDistance(BaseY,y),CalculateDistance(BaseZ,z))
  78. end
  79.  
  80. function init()
  81.  
  82. end
  83. init()
  84. MoveDownwardByOne()
Advertisement
Add Comment
Please, Sign In to add comment