Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ot=term
- local nt={}
- local mod=peripheral.find("modem")
- mod.open(545)
- local function call_remote(k,...)
- args={...}
- mod.transmit(555,545,{"NSA",k,args})
- end
- for k,v in pairs(term) do
- nt[k]=function(...) call_remote(k,...) return ot[k](...) end
- print("Hooked: "..k)
- os.sleep(0)
- end
- _G.term=nt
- nt.clear()
- nt.setCursorPos(1,1)
- local on=true
- while on do
- local cmd=""
- io.write(shell.dir()..": ")
- local loop=true
- term.setCursorBlink(true)
- while loop do
- name,key,port,_,msg=os.pullEvent()
- if name=="modem_message" then
- if port==545 then
- os.queueEvent(msg[1],msg[2])
- end
- elseif name=="key" then
- if key==keys.enter then
- loop=false
- elseif key==keys.backspace then
- cmd=string.sub(cmd,1,-2)
- local x,y=term.getCursorPos()
- term.setCursorPos(x-1,y)
- term.write(" ")
- term.setCursorPos(x-1,y)
- else
- io.write(string.lower(string.char(key)))
- cmd=cmd..string.lower(string.char(key))
- end
- end
- end
- term.setCursorBlink(false)
- local x,y=term.getCursorPos()
- term.setCursorPos(1,y+1)
- if cmd=="exit" then
- on=false
- else
- shell.run(cmd)
- end
- end
- _G.term=ot
- print("exited")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement