Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = { ... }
- if #tArgs ~= 1 then
- print("Useage: " .. fs.getName(shell.getRunningProgram()) .. " <receiverID>")
- end
- -- Opens any modem found on the computer.
- function openModem()
- for sideIndex, side in pairs(rs.getSides()) do
- if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
- rednet.open(side)
- return
- end
- end
- print("No modem found. Aborting.")
- error()
- end
- -- Closes any modem found on the computer.
- function closeModem()
- for sideIndex, side in pairs(rs.getSides()) do
- if peripheral.isPresent(side) and peripheral.getType(side) == "modem" then
- rednet.close(side)
- end
- end
- end
- -- Check for restoration.
- if tArgs[1] == "restore" then
- term.restore()
- closeModem()
- return
- end
- openModem()
- local receiverID = tonumber(tArgs[1])
- local oldTerm = {}
- local sendTerm = {}
- function wrap(functionName)
- return function(...)
- rednet.send(receiverID, textutils.serialize({funcName = functionName, params = {...}}))
- return oldTerm[functionName](...)
- end
- end
- for functionName, functionObject in pairs(term.native) do
- oldTerm[functionName] = functionObject
- end
- for functionName, functionObject in pairs(term.native) do
- if type(functionName) == "string" and type(functionObject) == "function" then
- sendTerm[functionName] = wrap(functionName)
- end
- end
- term.redirect(sendTerm)
- term.clear()
- term.setCursorPos(1, 1)
- print("Transmitting to " .. receiverID)
Advertisement
Add Comment
Please, Sign In to add comment