Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local modem = peripheral.wrap("right")
- modem.open(999)
- modem.open(997)
- modem.open(995)
- while true do
- local event, modemSide, senderChannel, replyChannel, message, senderDistance = os.pullEvent("modem_message")
- print("I just received a message on channel: "..senderChannel.."Respond on:"..replyChannel)
- print(message)
- if(senderChannel==999) then
- local file = fs.open("Locked.lua","r")
- local check = file.readLine()
- local isLocked =false;
- for line in file.readLine do
- if(line==message.."") then
- isLocked=true;
- end
- end
- if(isLocked) then
- modem.transmit(998,997,"Locked")
- else
- modem.transmit(998,997,"Go")
- end
- file.close()
- elseif (senderChannel==997) then
- file = fs.open(message..".lua","r")
- modem.transmit(996,995,file.readAll())
- local lFile = fs.open("Locked.lua","a")
- lFile.write(message.."\n")
- lFile.close()
- elseif(senderChannel==995) then
- local fname = string.sub(message,1,1)
- local fcontents= string.sub(message,2,-1)
- file = fs.open(fname..".lua","w")
- file.write(fcontents)
- file.close()
- local lFile = fs.open("Locked.lua","r")
- local temp = ""
- for line in lFile.readLine do
- if(line==fname.."") then
- print("removed file lock:"..line)
- else
- temp=temp.."\n"+line
- end
- end
- lFile.close()
- lFile = fs.open("Locked.lua","w")
- lFile.write(temp)
- lFile.close()
- modem.transmit(994,995,"Success")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment