EdgeLordKirito

InitTurtle Test

May 29th, 2023
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.57 KB | None | 0 0
  1. FUELVALUE = 0
  2. Facing = 0
  3. MASTERID = 0
  4. ACTIVE = true
  5. ChestX,ChestY,ChestZ = 0,0,0
  6. FuelX,FuelY,FuelZ = 0,0,0
  7. StartX,StartY,StartZ = 0,0,0
  8. SavedX,SavedY,SavedZ = 0,0,0
  9. DISTANCETOHOMEBASE = 0
  10.  
  11.  
  12. function SetChestCoords(x,y,z)
  13. ChestX = x
  14. ChestY = y
  15. ChestZ = z
  16. end
  17.  
  18. function SetFuelCoords(x,y,z)
  19. FuelX = x
  20. FuelY = y
  21. FuelZ = z
  22. end
  23.  
  24. function SetSavedCoords(x,y,z)
  25. SavedX = x
  26. SavedY = y
  27. SavedZ = z
  28. end
  29.  
  30. function SetStartCoords(x,y,z)
  31. StartX = x
  32. StartY = y
  33. StartZ = z
  34. end
  35.  
  36. function EnterWaitModeAndReturnMessage()
  37. local id,message,protocol = rednet.receive()
  38. return id,message,protocol
  39. end
  40.  
  41. function MySplit (inputstr, sep)
  42. if sep == nil then
  43. sep = "%s"
  44. end
  45. local t={}
  46. for str in string.gmatch(inputstr, "([^"..sep.."]+)") do
  47. table.insert(t, str)
  48. end
  49. return t
  50. end
  51.  
  52.  
  53.  
  54. function InitTurtle()
  55. local id, fuelMessage = EnterWaitModeAndReturnMessage()
  56. local id, chestMessage = EnterWaitModeAndReturnMessage()
  57. local fuelCoords = MySplit(fuelMessage)
  58. local chestCoords = MySplit(chestMessage)
  59. local currentX,currentY,currentZ = gps.locate()
  60. SetFuelValue(1)
  61. SetFuelCoords(fuelCoords[1],fuelCoords[2],fuelCoords[3])
  62. print(("%d %d %d"):format(fuelCoords[1],fuelCoords[2],fuelCoords[3]))
  63. print(("%d %d %d"):format(chestCoords[1],chestCoords[2],chestCoords[3]))
  64. SetChestCoords(chestCoords[1],chestCoords[2],chestCoords[3])
  65. SetStartCoords(currentX,currentY,currentZ)
  66. SetSavedCoords(currentX,currentY,currentZ)
  67. end
  68.  
  69. InitTurtle()
Advertisement
Add Comment
Please, Sign In to add comment