Keltaith

Start of Broadcast Programn

May 15th, 2012
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.02 KB | None | 0 0
  1. local broadcasttime = 0
  2. local counttime = 0
  3.  
  4. local function createtime()
  5.  
  6.  
  7.     term.clear()
  8.     term.setCursorPos( 1,1 )
  9.     print( "Set the settings.")
  10.  
  11.     write("How often should trees harvest?")
  12.     broadcasttime = tonumber(read())
  13.     counttime = broadcasttime
  14.  
  15.     file = io.open("timesettings.txt" , "w")
  16.     if file == nil then
  17.         return
  18.     end
  19.  
  20.     file:write( broadcasttime )
  21.     file:write( "\n" )
  22.  
  23.     file:close()
  24.  
  25.     term.clear()
  26.     term.setCursorPos( 1,1 )
  27.     print( "Working" )
  28.  
  29.  
  30. end
  31.  
  32.  
  33.  
  34. local function loadtime()
  35.  
  36.     file = io.open( "timesettings.txt" , "r")
  37.     while true do
  38.         line = file:read()
  39.         if line == nil then break end
  40.  
  41.         broadcasttime = tonumber(line)
  42.        
  43.         file:close()
  44.  
  45.         return true
  46.  
  47.     end
  48.  
  49.     file:close()
  50.  
  51.     return false
  52.  
  53. end
  54.  
  55. term.clear()
  56. term.setCursorPos ( 1,1 )
  57. print( "Starting Logger Broadcast...")
  58.  
  59. if fs.exists( "timesettings.txt") then
  60.     if not loadtime() then
  61.         createtime()
  62.     end
  63.  
  64.     term.clear()
  65.     term.setCursorPos( 1,1 )
  66.     print( "Cycling")
  67. else
  68.     createtime()
  69. end
  70.  
  71. rednet.open("right")
Advertisement
Add Comment
Please, Sign In to add comment