Advertisement
cul8ter

rsh

Sep 5th, 2023 (edited)
1,121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.17 KB | None | 0 0
  1. local ot=term
  2. local nt={}
  3. local mod=peripheral.find("modem")
  4. mod.open(545)
  5. local function call_remote(k,...)
  6.     args={...}
  7.     mod.transmit(555,545,{"NSA",k,args})
  8. end
  9. for k,v in pairs(term) do
  10.     nt[k]=function(...) call_remote(k,...) return ot[k](...) end
  11.     print("Hooked: "..k)
  12.     os.sleep(0)
  13. end
  14. _G.term=nt
  15. nt.clear()
  16. nt.setCursorPos(1,1)
  17. local on=true
  18. while on do
  19.     local cmd=""
  20.     io.write(shell.dir()..": ")
  21.     local loop=true
  22.     term.setCursorBlink(true)
  23.     while loop do
  24.         name,key,port,_,msg=os.pullEvent()
  25.         if name=="modem_message" then
  26.             if port==545 then
  27.                 os.queueEvent(msg[1],msg[2])
  28.             end
  29.         elseif name=="key" then
  30.             if key==keys.enter then
  31.                 loop=false
  32.             elseif key==keys.backspace then
  33.                 cmd=string.sub(cmd,1,-2)
  34.                 local x,y=term.getCursorPos()
  35.                 term.setCursorPos(x-1,y)
  36.                 term.write(" ")
  37.                 term.setCursorPos(x-1,y)
  38.             else
  39.                 io.write(string.lower(string.char(key)))
  40.                 cmd=cmd..string.lower(string.char(key))
  41.             end
  42.         end
  43.     end
  44.     term.setCursorBlink(false)
  45.     local x,y=term.getCursorPos()
  46.     term.setCursorPos(1,y+1)
  47.     if cmd=="exit" then
  48.         on=false
  49.     else
  50.         shell.run(cmd)
  51.     end
  52. end
  53. _G.term=ot
  54. print("exited")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement