Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Server Program
- local modemSide = "top" -- Adjust the side where your modem is connected
- local serverID = "exampleServer" -- Set a unique server ID
- rednet.open(modemSide)
- while true do
- local _, message = rednet.receive(serverID)
- if message == "list_files" then
- local files = fs.list("/network")
- rednet.send(_, textutils.serialize(files))
- elseif message:match("^delete_file:(.+)$") then
- local _, fileName = message:match("^delete_file:(.+)$")
- fs.delete("/network/" .. fileName)
- rednet.send(_, "File deleted.")
- elseif message:match("^move_file:(.+),(.+)$") then
- local _, source, destination = message:match("^move_file:(.+),(.+)$")
- fs.move("/network/" .. source, "/network/" .. destination)
- rednet.send(_, "File moved.")
- elseif message:match("^copy_file:(.+),(.+)$") then
- local _, source, destination = message:match("^copy_file:(.+),(.+)$")
- fs.copy("/network/" .. source, "/network/" .. destination)
- rednet.send(_, "File copied.")
- elseif message:match("^edit_file:(.+)$") then
- local _, fileName = message:match("^edit_file:(.+)$")
- shell.run("edit /network/" .. fileName)
- rednet.send(_, "File edited.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement