Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2013
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.42 KB | None | 0 0
  1. --[[
  2. CCPresenter by TheOriginalBIT
  3. Version 1.0
  4. First Created: 22 March 2013
  5. Last Updated: 22 March 2013
  6.  
  7. Inspired by, and continuation of: http://www.computercraft.info/forums2/index.php?/topic/11003-remote-presentation/
  8. ]]
  9.  
  10.  --error without line numbers and stuff
  11. local function nonVerboseError(msg)
  12.   printError(msg)
  13.   error()
  14. end
  15.  
  16. -- make a copy of term
  17. if not term.done then
  18.   oldTerm = {}
  19.   for k,v in pairs(term) do
  20.     oldTerm[k] = v
  21.   end
  22.   term.done = true
  23. end
  24.  
  25. local function findPeripheral( t )
  26.   for _,s in pairs(rs.getSides()) do
  27.     if peripheral.getType(s) == t then
  28.       return s
  29.     end
  30.   end
  31.  
  32.   nonVerboseError('No '..t..' attached to the computer')
  33. end
  34.  
  35. rednet.open( findPeripheral( 'modem' ) )
  36.  
  37. local function writePacket(method, ...)
  38.   oldTerm[method]( ... )
  39.  
  40.   local msg = method..':'..table.concat( {...}, ':' )
  41.  
  42.   rednet.broadcast(msg)
  43. end
  44.  
  45. term.write = function( ... ) writePacket('write', ...) end
  46. term.setBackgroundColor = function( c ) writePacket('setBackgroundColor', c) end
  47. term.setTextColor = function( c ) writePacket('setTextColor', c) end
  48. term.setCursorPos = function(x, y) writePacket('setCursorPos', x, y) end
  49. term.setCursorBlink = function( b ) writePacket('setCursorBlink', b) end
  50. term.clear = function() writePacket("clear") end
  51. term.clearLine = function() writePacket("clearLine") end
  52. term.scroll = function(n) writePacket('scroll', n) end
  53. term.done = true
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement