Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local nBroadcastTime = 300
- local nTime = 1500
- local function createtime()
- term.clear()
- term.setCursorPos( 1,1 )
- print( "Set the settings.")
- write("How often should trees harvest?")
- nBroadcastTime = tonumber(read())
- file = io.open("timesettings.txt" , "w")
- if file == nil then
- return
- end
- file:write( nBroadcastTime )
- file:write( "\n" )
- file:close()
- term.clear()
- term.setCursorPos( 1,1 )
- print( "Working" )
- end
- local function loadtime()
- file = io.open( "timesettings.txt" , "r")
- while true do
- line = file:read()
- if line == nil then break end
- nBroadcastTime = tonumber(line)
- file:close()
- return true
- end
- file:close()
- return false
- end
- term.clear()
- term.setCursorPos ( 1,1 )
- print( "Starting Logger Broadcast...")
- if fs.exists( "timesettings.txt") then
- if not loadtime() then
- createtime()
- end
- term.clear()
- term.setCursorPos( 1,1 )
- print( "Cycling")
- stopTimer()
- else
- createtime()
- end
- rednet.open("right")
- local stopTimer = os.startTimer(nTime)
- local broadcastTimer = os.startTimer(nBroadcastTime)
- while true do
- local evt, arg = os.pullEvent()
- if evt == "timer" then
- if arg == broadcastTimer then
- rednet.broadcast("startLoging")
- broadcastTimer = os.startTimer(nBroadcastTime)
- elseif arg == stopTimer then
- break
- end
- elseif evt == "char" then
- if arg == "s" then
- break
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment