Marlingaming

CC Tweaked Registered Places Server

Feb 16th, 2022
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. local Protocol = "5254"
  2.  
  3. function GiveLocations(Cat)
  4. local List = fs.list("Locations")
  5. local Items = {}
  6. local Cords = {}
  7. local Name
  8. local Owner
  9.  
  10. for i = 1, #List do
  11. local file = fs.open(fs.combine("Locations",List[i]),"r")
  12. Name = file.readLine()
  13. Cords = textutils.unserialize(file.readLine())
  14. Owner = file.readLine()
  15. if file.readLine == Cat then Items[#Items + 1] = Name end
  16. file.close()
  17. end
  18.  
  19. return Items
  20. end
  21.  
  22. function AddLoc(Name,Cat)
  23. local file = fs.open(fs.combine("Locations",Name),"w")
  24. file.writeLine(Name)
  25. file.writeLine("0,0")
  26. file.writeLine("none")
  27. file.close()
  28. end
  29.  
  30. function Loop()
  31. local id, message, protocol
  32. repeat
  33. id, message, protocol = rednet.receive()
  34. until protocol == Protocol
  35. if string.sub(message,1,3) == "Fin" then
  36. rednet.sent(id,textutils.serialize(GiveLocations(string.sub(message,4,7))))
  37. elseif string.sub(message,1,3) == "Add" then
  38. AddLoc(string.sub(message,8),string.sub(message,4,7))
  39. end
  40. Loop()
  41. end
  42.  
  43. Loop()
Advertisement
Add Comment
Please, Sign In to add comment