Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Define the target computer's ID here
- local targetComputerID = 1 -- Change this to the ID of your target computer
- -- Function to open the modem on the source computer
- local function openModem()
- local modemSide
- for _, side in ipairs(rs.getSides()) do
- if peripheral.getType(side) == "modem" then
- modemSide = side
- break
- end
- end
- if modemSide and not rednet.isOpen(modemSide) then
- rednet.open(modemSide)
- end
- end
- -- Function to send a file from the source computer to the target computer
- local function sendFile(sourcePath, targetPath)
- local file = fs.open(sourcePath, "r")
- if file then
- local contents = file.readAll()
- file.close()
- rednet.send(targetComputerID, {targetPath, contents}, "fileTransfer")
- else
- end
- end
- -- Main function to send non-default programs to the target computer
- local function sendNonDefaultPrograms()
- openModem()
- local files = fs.list("")
- for _, file in ipairs(files) do
- if fs.isDir(file) == false and file ~= "startup" then
- sendFile(file, file)
- end
- end
- end
- -- Main program execution
- sendNonDefaultPrograms()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement