Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- UserID = 1
- pass = " " --10 caractere
- local Authenticate = {" "," 1 1"}
- local User = {" ","debug"}
- local function openRednet()
- local listOfSides = rs.getSides()
- for i = 1,6 do
- if peripheral.isPresent(listOfSides[i]) and peripheral.getType(listOfSides[i]) == "modem" then
- rednet.open(listOfSides[i])
- return listOfSides[i]
- end
- end
- end
- modemOn = openRednet()
- if not modemOn then
- print("No WIFI Modem\nPress any key to return to exit")
- os.pullEvent("key")
- return
- end
- function os.pullEventRaw(...)
- local e1,e2,e3,e4,e5 = coroutine.yield(...)
- if e1 == "rednet_message" and e2 == UserID then
- local a = string.sub(e3,1,3)
- if a == "key" then
- return "key",tonumber(string.sub(e3,4,string.len(e3)))
- elseif a == "cha" then
- return "char",string.sub(e3,4,4)
- end
- end
- return e1,e2,e3,e4,e5
- end
- remote = {}
- function remote.write(s)
- rednet.send(UserID,"WRT"..s)
- end
- function remote.clear()
- rednet.send(UserID,"CLR")
- end
- function remote.clearLine()
- rednet.send(UserID,"CLL")
- end
- function remote.setCursorBlink(s)
- rednet.send(UserID,"SCB"..tostring(s))
- end
- function remote.setCursorPos(X,Y)
- rednet.send(UserID,"SCP"..textutils.serialize({X,Y}))
- end
- function remote.getSize()
- rednet.send(UserID,"GSZ")
- while true do
- local w1,w2,w3 = os.pullEvent("rednet_message")
- if string.sub(w3,1,3) == "SIZ" then
- local a = textutils.unserialize(string.sub(w3,4,string.len(w3)))
- return a[1],a[2]
- end
- end
- end
- function remote.getCursorPos()
- rednet.send(userID,"GCP")
- while true do
- local w1,w2,w3 = os.pullEvent("rednet_message")
- if string.sub(w3,1,3) == "pos" then
- local a = textutils.unserialize(string.sub(w3,4,string.len(w3)))
- return a[1],a[2]
- end
- end
- end
- function remote.scroll(nLines)
- rednet.send(UserID,"SCR"..tostring(nLines))
- end
- term.clear()
- term.setCursorPos(1,1)
- print("Remote Terminal Started")
- while true do
- local q1,q2,q3,q4,q5 = os.pullEvent()
- print(tostring(q1).." "..tostring(q2))
- if q1 == "rednet_message" then
- local test = string.sub(q3,1,10)
- local DAT = textutils.unserialize(string.sub(q3,11,string.len(q3)))
- if test == pass and Authenticate[1] == DAT then
- term.clear()
- term.setCursorPos(1,1)
- print("open Connection")
- rednet.send(q2,"Request Accepted")
- sleep(5)
- UserID = q2
- term.clear()
- term.setCursorPos(1,1)
- print("User "..User[1].." online")
- break
- elseif test == Authenticate[2] then
- term.clear()
- term.setCursorPos(1,1)
- print("debug du system")
- sleep(10)
- os.reboot()
- end
- end
- end
Add Comment
Please, Sign In to add comment