Advertisement
goldfiction

turtle report

Aug 10th, 2023
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. ###########
  2. Turtle: (put this as a separate program for easiness of use, just put the move commands before the rednet command)
  3. ###########
  4.  
  5.  
  6. turtle.turnLeft()
  7. turtle.forward()
  8. turtle.turnRight()
  9. turtle.forward()
  10.  
  11. rednet.open("right")
  12. local serverId = 3 -- Change to your server ID --
  13.  
  14.  
  15. -- Do not change anything below this point --
  16. local name = os.getComputerLabel()
  17. local done = false
  18. local myId = os.computerID()
  19.  
  20. while done == false do
  21. rednet.send(serverId,name)
  22. senderId,message,distance = rednet.receive(5)
  23. if senderId == serverId then
  24. if message == "Valid" then
  25. print("Accepted")
  26. rednet.close("right")
  27. shell.run ("shutdown")
  28. else
  29. print("ID / Name Mismatch")
  30. shell.run ("shutdown")
  31. end
  32. end
  33. end
  34.  
  35. ##############
  36. Computer:
  37. ##############
  38.  
  39. local myid = os.computerID()
  40. local turtlelist = { 0, 5, 6 } -- Enter the ID of all your Mining Turtles Here --
  41. local turtlename = { "DIGGE01", "DIGGE02", "DIGGE03" } -- Enter the Name/ Label you have given your turtle here --
  42.  
  43. mon=peripheral.wrap("left")
  44. print("Turtle Monitor Terminal")
  45. rednet.open("top") -- Edit to what ever side you modem is on --
  46.  
  47.  
  48. print("Computer id for Monitor Terminal is "..tostring(myid))
  49.  
  50. function findIndexForId(id)
  51. for i,v in ipairs(turtlelist) do
  52. if id == v then
  53. return i
  54. end
  55. end
  56. return 0
  57. end
  58.  
  59. function checkTurtleForName(id,tlabel)
  60. local i = findIndexForId(id)
  61. if i == 0 then
  62. return -1
  63. end
  64. if turtlename == tlabel then
  65. return 1
  66. else
  67. return 0
  68. end
  69. end
  70.  
  71. local isValid = 0
  72.  
  73. while true do
  74. local timeString = textutils.formatTime(os.time(),false)
  75. senderId, message, distance = rednet.receive()
  76. isValid = checkTurtleForName(senderId, message)
  77.  
  78. if isValid == -1 then
  79. print("A Turtle"..senderId.." sent us a request but is not in our list")
  80. elseif isValid == 1 then
  81. rednet.send(senderId, "Valid")
  82. mon.scroll(1)
  83. mon.setCursorPos(1,5)
  84. mon.write("Mining Complete: "..senderId.." "..message.." at "..timeString)
  85. else
  86. rednet.send(senderId, "Not Valid")
  87. mon.scroll(1)
  88. mon.setCursorPos(1,5)
  89. mon.write("Error from "..senderId.." "..message.." at "..timeString)
  90. end
  91. end
  92.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement