Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Log V1.0 program made by Anonomit
- term.clear()
- term.setCursorPos( 1, 1 )
- for i, side in ipairs( rs.getSides() ) do
- if peripheral.isPresent( side ) then
- if peripheral.getType( side ) == "modem" then
- break --for _, side in ipairs( rs.getSides() )
- end --if peripheral.getType( side ) == "modem"
- end --if peripheral.isPresent( side )
- if i == #rs.getSides() then
- print( "No Modem Attached" )
- sleep( 1 )
- shell.exit()
- end --if i == #rs.getSides()
- end --for i, side in ipairs( rs.getSides() )
- for _, side in pairs( rs.getSides() ) do
- rednet.open( side )
- end --for _, side in pairs( rs.getSides() )
- local function round( _number, _dp)
- local nMultiple = 10^( _dp or 0 )
- return math.floor( _number * nMultiple + 0.5 ) / nMultiple
- end --local function round( _number, _dp )
- local tArgs = { ... }
- if tArgs[1] == "recreate" then
- if fs.exists( "logSettings" ) then
- fs.delete( "logSettings" )
- end --if fs.exists( "logSettings" )
- end --if tArgs[1] == "recreate"
- local nBroadcastID
- local xTerm, yTerm = term.getSize()
- term.clear()
- if fs.exists( "logSettings" ) then
- local file = fs.open( "logSettings", "r" )
- nBroadcastID = tonumber( file.readLine() )
- file.close()
- else --fs.exists( "logSettings" )
- local xCursorPos, yCursorPos = term.getCursorPos()
- while nBroadcastID == nil do
- term.clear()
- term.setCursorPos( 1, 1 )
- print( "Log" )
- for i = 1, xTerm - 1 do
- write( "~" )
- end --for i = 1, xTerm - 1
- term.setCursorPos( 1, 3 )
- rednet.broadcast( "broadcastPing" )
- local param1, param2, param3 = rednet.receive( 0.1 )
- if param2 then
- term.setCursorPos( xCursorPos, yCursorPos + 1 )
- term.clearLine()
- write( ">Broadcast Console #" .. param1 .. " is " .. round( param3, 0 ) .. " away" )
- else --param2
- write( ">No Broadcast Consoles Found Nearby" )
- end --if param2
- term.setCursorPos( xCursorPos, yCursorPos )
- term.clearLine()
- write( "Broadcast Console ID: " )
- nBroadcastID = tonumber( read() )
- if nBroadcastID == nil then
- write( "Invalid Value" )
- sleep( 0.5 )
- term.clearLine()
- elseif nBroadcastID < 0 then
- write( "Invalid Value" )
- sleep( 0.5 )
- term.clearLine()
- nBroadcastID = nil
- else --nBroadcastID == nil
- rednet.send( nBroadcastID, "broadcastPing" )
- local param1, param2, param3 = rednet.receive( 0.1 )
- if param2 == "broadcastPong" then
- local file = fs.open( "logSettings", "w" )
- file.write( tostring( param1 ) )
- file.close()
- else --if param2 == "logPong"
- term.clearLine()
- write( "No Response" )
- sleep( 1 )
- term.clearLine()
- nBroadcastID = nil
- end --if param2 ~= "logPong"
- end --if nBroadcastID == nil
- end --while nBroadcastID == nil
- term.clearLine()
- end --if fs.exists( "logSettings" )
- rednet.send( nBroadcastID, "loggerRequestStart" )
- local loggerDoneLogging = 0
- local loggerLogging = 0
- local loggerLowSaplings = 0
- local loggerNoSaplings = 0
- term.clear()
- term.setCursorPos( 1, 1 )
- print( "Log" )
- for i = 1, xTerm - 1 do
- write( "~" )
- end --for i = 1, xTerm - 1
- term.setCursorPos( 1, 3 )
- local param1, param2, param3 = rednet.receive( 0.1 )
- if param2 then
- for id, state in pairs( textutils.unserialize( param2 ) ) do
- if state == "loggerDoneLogging" then
- loggerDoneLogging = loggerDoneLogging + 1
- elseif state == "loggerLogging" then
- loggerLogging = loggerLogging + 1
- elseif state == "loggerLowSaplings" then
- loggerLowSaplings = loggerLowSaplings + 1
- elseif state == "loggerNoSaplings" then
- loggerNoSaplings = loggerNoSaplings + 1
- end --if state == "loggerDoneLogging"
- end --for id, state in pairs( textutils.unserialize( param2 ) )
- if loggerLogging > 0 or loggerLowSaplings > 0 or loggerNoSaplings > 0 then
- print( ( loggerDoneLogging == 0 and "No" or loggerDoneLogging ) .. ( loggerDoneLogging == 1 and " logger has" or " loggers have" ) .. " finished." )
- if loggerLowSaplings > 0 then
- print( loggerLowSaplings .. ( loggerLowSaplings == 1 and " logger is" or " loggers are" ) .. " low on saplings." )
- end --if loggerLowSaplings > 0
- if loggerNoSaplings > 0 then
- print( loggerNoSaplings .. ( loggerNoSaplings == 1 and " logger has" or " loggers have" ) .. " no saplings." )
- end --if loggerNoSaplings > 0
- else --loggerLogging > 0 or loggerLowSaplings > 0 or loggerNoSaplings > 0
- print( "Logging Started" )
- end --if loggerLogging > 0 or loggerLowSaplings > 0 or loggerNoSaplings > 0
- else --param2
- print( "No Response" )
- print( "Use '" .. shell.getRunningProgram() .. " recreate' to change broadcast console ID" )
- end --if param2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement