Marlingaming

Personal Data Server Manager

Sep 10th, 2021 (edited)
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. --this program deals with all the Personal Data of the facility
  2. local Target = nil
  3. local Action = nil
  4. local Contacted_ID = nil
  5. local Current_Protocol = nil
  6. local Location = nil
  7.  
  8. start()
  9.  
  10. function start()
  11. Standby()
  12. end
  13.  
  14. function Standby()
  15. rednet.open("top")
  16. repeat
  17. local id, message, protocol = rednet.receive()
  18. until message == "Test Update" or message == "Schedule" or message == "Personal File Update" or message == "Add Player"
  19. Contacted_ID = id
  20. Current_Protocol = protocol
  21. if message == "Test Update" then
  22. PersonalTaskEditor()
  23. elseif message == "Schedule" then
  24. PersonalScheduleEditor()
  25. elseif message == "Personal File Update" then
  26. PersonalProfileEditor()
  27. elseif message == "Add Player" then
  28. PersonalFileEditor()
  29. end
  30. end
  31.  
  32. function PersonalTaskManager()
  33. rednet.open("top")
  34. repeat
  35. local id, message = rednet.receive()
  36. until id == Contacted_ID
  37. Target = message
  38. rednet.send(Contacted_ID,"Found",Current_Protocol)
  39. repeat
  40. local id, message = rednet.receive()
  41. until id == Contacted_ID
  42. location = message
  43. rednet.send(Contacted_ID,"y",Current_Protocol)
  44. repeat
  45. local id, message = rednet.receive()
  46. until id == Contacted_ID
  47. Action = message
  48. local file = fs.open("PersonalTasks","a")
  49. local i = 1
  50. while true do
  51. if file.readLine(i) == Target then
  52. break
  53. else
  54. i = i + 1
  55. end
  56. end
  57. file.setCursorPos(1,i+1)
  58. file.clearLine(i+1)
  59. file.write(Action)
  60. file.close()
  61. rednet.send(Contacted_ID,"Updated",Current_Protocol)
  62. Target = nil
  63. Action = nil
  64. Contacted_ID = nil
  65. Current_Protocol = nil
  66. Location = nil
  67. Standby()
  68. end
  69.  
  70. function PersonalScheduleEditor()
  71. rednet.open("top")
  72. repeat
  73. local id, message = rednet.receive()
  74. until id == Contacted_ID
  75. Target = message
  76. rednet.send(Contacted_ID,"Method",Current_Protocol)
  77. repeat
  78. local id, message = rednet.receive()
  79. until id == Contacted_ID
  80. if message == "view" then
  81. rednet.send(Contacted_ID,"sending file",Current_Protocol)
  82. local file = fs.open(Target.."_Schedule","r")
  83. local fileContents = file.readAll()
  84. file.close()
  85. rednet.send(Contacted_ID,fileContents,Current_Protocol)
  86. elseif message == "Set" then
  87. rednet.send(Contacted_ID,"ready",Current_Protocol)
  88. repeat
  89. local id, message = rednet.receive()
  90. until id == Contacted_ID
  91. local file = fs.open(Target.."_Schedule","w")
  92. file.clear()
  93. file.write(message)
  94. file.close()
  95. rednet.send(Contacted_ID,"Saved",Current_Protocol)
  96. end
  97. end
Add Comment
Please, Sign In to add comment