Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- reciver
- mk2
- ]]--
- local oldPrintError = printError
- printError = function(...)
- local data = {...}
- local file = fs.open("log","w")
- for i = 1,#data do
- file.write(tostring(data[1].." "))
- end
- file.write("\n")
- file.close()
- oldPrintError(unpack(data))
- end
- local function findDevice(sType)
- for _,sSide in pairs(rs.getSides()) do
- if peripheral.isPresent(sSide) and peripheral.getType(sSide) == sType then
- return sSide,peripheral.wrap(sSide)
- end
- end
- end
- local modemSide,modem = findDevice("modem")
- local freq = 0
- local function main()
- while true do
- local event = {os.pullEvent()}
- if event[1] == "modem_message" then
- local test,tInput = pcall(textutils.unserialize,event[5])
- pcall(
- function()
- local sFunk = tInput[1]
- table.remove(tInput,1)
- term[sFunk](unpack(tInput))
- end
- )
- else
- table.insert(event,1,"INS")
- modem.transmit(freq,freq,textutils.serialize(event))
- end
- end
- end
- if modemSide then
- print(" --- Remote access client --- ")
- while true do
- write("Choose Freq : ")
- local temp = read()
- if string.lower(temp) == "exit" then
- print(" --- Exiting program --- ")
- return
- end
- temp = tonumber(temp)
- if type(temp) == "number" and temp >= 0 and temp <= 65535 then
- freq = temp
- break
- end
- print("ERROR : Range 0 - 65535 or Exit")
- end
- write("User : ")
- local user = read()
- write("Password : ")
- local pass = read("*")
- print("Opening modem : "..modemSide.." Freq : "..tostring(freq))
- modem.open(freq)
- modem.transmit(freq,freq,textutils.serialize({user = user,password = pass}))
- os.pullEvent()
- modem.transmit(freq,freq,textutils.serialize({cmd = "REPLY-SCP",test = term.isColor()}))
- term.clear()
- term.setCursorPos(1,1)
- main()
- else
- print("ERROR : Failed to find modem ")
- end
- --[[
- if modemSide then
- modem.open(freq)
- modem.transmit(freq,freq,textutils.serialize({user = "test",password = "test"}))
- os.pullEvent()
- modem.transmit(freq,freq,textutils.serialize({cmd = "REPLY-SCP",test = term.isColor()}))
- main()
- else
- print("ERROR : Failed to find modem ")
- end
- ]]--
- --[[
- print(" --- Remote access server --- ")
- while true do
- write("Choose Freq : ")
- local temp = read()
- if string.lower(temp) == "exit" then
- print(" --- Server stoping --- ")
- return
- end
- temp = tonumber(temp)
- if type(temp) == "number" and temp >= 0 and temp <= 65535 then
- freq = temp
- break
- end
- print("ERROR : Range 0 - 65535 or Exit")
- end
- write("User : ")
- user = read()
- write("Password : ")
- pass = read("*")
- print("Opening modem : "..modemSide.." Freq : "..tostring(freq))
- modem.open(freq)
- main()
- ]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement