Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Protocol = "5254"
- function GiveLocations(Cat)
- local List = fs.list("Locations")
- local Items = {}
- local Cords = {}
- local Name
- local Owner
- for i = 1, #List do
- local file = fs.open(fs.combine("Locations",List[i]),"r")
- Name = file.readLine()
- Cords = textutils.unserialize(file.readLine())
- Owner = file.readLine()
- if file.readLine == Cat then Items[#Items + 1] = Name end
- file.close()
- end
- return Items
- end
- function AddLoc(Name,Cat)
- local file = fs.open(fs.combine("Locations",Name),"w")
- file.writeLine(Name)
- file.writeLine("0,0")
- file.writeLine("none")
- file.close()
- end
- function Loop()
- local id, message, protocol
- repeat
- id, message, protocol = rednet.receive()
- until protocol == Protocol
- if string.sub(message,1,3) == "Fin" then
- rednet.sent(id,textutils.serialize(GiveLocations(string.sub(message,4,7))))
- elseif string.sub(message,1,3) == "Add" then
- AddLoc(string.sub(message,8),string.sub(message,4,7))
- end
- Loop()
- end
- Loop()
Advertisement
Add Comment
Please, Sign In to add comment