Guest User

mirror

a guest
Mar 6th, 2015
382
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.85 KB | None | 0 0
  1.  
  2. local function mirror(redir)
  3.   redir=redir or term.current()
  4.   mirror = {
  5.     write = function(str)
  6.         str=tostring(str)
  7.         local w,h=redir.getSize()
  8.         local x,y=redir.getCursorPos()
  9.         redir.setCursorPos(x-#str+1,y)
  10.         redir.write(str:reverse())
  11.         redir.setCursorPos(x-#str,y)
  12.       end,
  13.     getCursorPos = function()
  14.         local x,y=redir.getCursorPos()
  15.         local w,h=redir.getSize()
  16.         return w-x+1,y
  17.       end,
  18.     setCursorPos = function(x,y)
  19.         local w,h=redir.getSize()
  20.         redir.setCursorPos(w-x+1,y)
  21.       end,
  22.   }
  23.  
  24.   for k,v in pairs(redir) do
  25.     if mirror[k]==nil then
  26.       mirror[k]=v
  27.     end
  28.   end
  29.  
  30.   return mirror
  31. end
  32.  
  33. local prev=term.redirect(mirror())
  34. term.clear()
  35. term.setCursorPos(1,1)
  36.  
  37. shell.run("shell")
  38.  
  39. term.redirect(prev)
  40. term.clear()
  41. term.setCursorPos(1,1)
Advertisement
Add Comment
Please, Sign In to add comment