XoXFaby

XoXLost

Oct 31st, 2012
706
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.74 KB | None | 0 0
  1. oldevent = os.pullEvent
  2. os.pullEvent = os.pullEventRaw
  3. oldt = 6480
  4. if fs.exists("t") then
  5.     f = fs.open("t", "r")
  6.     oldt = tonumber(f.readAll())
  7.     f.close()
  8. end
  9.  
  10. while true do
  11.     math.randomseed = os.time()
  12.     mon = peripheral.wrap("top")
  13.     mon.setTextScale( 4 )
  14.     function clock()
  15.         t = 0
  16.         while true do
  17.             mon.write(math.floor( t / 60 ) .. ":" .. t % 60 )
  18.             sleep(0.001)
  19.             t = t + 129
  20.             mon.clear()
  21.             mon.setCursorPos(1, 1)
  22.             if t > 6420 then break end
  23.         end
  24.         t = oldt
  25.         while true do
  26.             if t < 60 then
  27.                 if not rs.getOutput("right") then
  28.                     rs.setOutput("right", true)
  29.                 end
  30.             elseif t < 240 then
  31.                 if not rs.getOutput("left") then
  32.                     rs.setOutput("left", true)
  33.                 end
  34.             else
  35.                 rs.setOutput("left", false)
  36.                 rs.setOutput("right", false)
  37.             end
  38.  
  39.             if t > 0 then
  40.                 mon.clear()
  41.                 mon.setCursorPos(1, 1)
  42.                 mon.write(math.floor( t / 60 ) .. ":" .. t % 60 )
  43.                 f = fs.open("t", "w")
  44.                 f.writeLine(t)
  45.                 f.close()
  46.                 sleep(1)
  47.                 t = t - 1
  48.                 rs.setOutput("bottom", false)
  49.             else
  50.                 rs.setOutput("bottom", true)
  51.                 while t <= 0 do
  52.                     mon.clear()
  53.                     mon.setCursorPos(1, 1)
  54.                     randstr = string.char(math.random(1,150),math.random(1,150),math.random(1,150),math.random(1,150),math.random(1,150),math.random(1,150) )
  55.                     mon.write(randstr)
  56.                     sleep(0.05)
  57.                 end
  58.             end
  59.         end
  60.     end
  61.  
  62.     function input()
  63.         sleep(10)
  64.         while true do
  65.             term.clear()
  66.             term.setCursorPos(1,1)
  67.             if t > 240 then
  68.                 sleep(2)
  69.             else
  70.                 input = read()
  71.                 if input == "4 8 15 16 23 42" then
  72.                     oldt = 6480
  73.                     rs.setOutput("bottom", false)
  74.                     rs.setOutput("right", false)
  75.                     rs.setOutput("left", false)
  76.                     return
  77.                 end
  78.  
  79.             end
  80.         end
  81.     end
  82.     parallel.waitForAny(clock,input)
  83. end
Advertisement
Add Comment
Please, Sign In to add comment