Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {[1]="coreplugin", [2]="1",}
- local idSender, msg = rednet.receive()
- local msgT = textutils.unserialize(msg)
- local idAdressee = msgT[1]
- local type = msgT[2]
- local body = msgT[3]
- if idAdressee == idServer then
- term.setTextColor(colors.yellow)
- print("Message for the server received")
- term.setTextColor(colors.black)
- if type == "#/program#" then
- local idSender, arg = rednet.receive()
- shell.run(body, arg)
- elseif type == "#/file#" then
- local idSender, toDo = rednet.receive()
- if toDo == "%save%" then
- local idSender, nameOfFile = rednet.receive()
- local file = fs.open("/usermade/"..nameOfFile, "w")
- file.write(body)
- file.close()
- rednet.send(tonumber(idSender), "<saved>")
- elseif toDo == "%run%" then
- loadstring(body)
- rednet.send(tonumber(idSender), "<executed>")
- else
- rednet.send(tonumber(idSender), "<error:fileinfo:wrongcommand>")
- end
- elseif type == "#/command#" then
- local idSender, command = rednet.receive()
- if command == "#/exit#" then
- return
- else
- rednet.send(tonumber(idSender), "<error:commandinfo:
- wrongcommand>")
- end
- else
- rednet.send(tonumber(idSender), "<error:typerequest:wrongtype>")
- end
- else
- term.setTextColor(colors.black)
- print("Request for : "..idAdressee.." received")
- rednet.send(tonumber(idAdressee), body)
- while true do
- local idReceiver, msgConfirm = rednet.receive(5)
- if msgConfirm == "<success:messagereceived>" then
- term.setTextColor(colors.green)
- print("Message successfully sent")
- term.setTextColor(colors.black)
- rednet.send(tonumber(idSender), "<success:messagesent>")
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment