--[[ CCPresenter by TheOriginalBIT Version 1.0 First Created: 22 March 2013 Last Updated: 22 March 2013 Inspired by, and continuation of: http://www.computercraft.info/forums2/index.php?/topic/11003-remote-presentation/ ]]-- local version = '1.0' local h = fs.open('ccpresenter_log', 'a') if #{...} > 0 then printError('this program does not support runtime arguments') return end local nonVerboseError = function(msg) printError(msg) error() end -- error without line numbers and stuff local findPeripheral = function( t ) for _,s in pairs(rs.getSides()) do if peripheral.getType(s) == t then return s end end nonVerboseError('No '..t..' attached to the computer') end local split = function(str, pat) local t = {} for s in str:gmatch('[^:]+') do table.insert(t, s) end return t end local log = function(msg) if h then h.write(msg..'\n') h.flush() end end local modemSide = findPeripheral( 'modem' ) rednet.open(modemSide) local function readPacket(method) method = textutils.unserialize(method) if term[ method._m ] then -- protect the call, since changing colours will error on a non-advanced or pre-CC1.4 computer pcall( term[ method._m ], unpack( method._a ) ) else log('received invalid command | $_day '..os.day()..' | $_time '..os.time()..' | $_clock '..os.clock()..' | $_cmd '..tostring(method)) end end term.clear() term.setCursorPos(1,1) log('========================================================= Day: '..os.day()..' Time: '..textutils.formatTime(os.time(), true)..' =========================================================') while true do local e = { os.pullEventRaw() } if e[1] == 'rednet_message' then if e[3] == 'service_closed' then print('Service disconnected...') sleep(1) term.clear() term.setCursorPos(1,1) break else readPacket( e[3] ) end elseif e[1] == 'terminate' then log('===== END SESSION LOG =====') break end end