Advertisement
NAPTlME

LightningTimer

Sep 2nd, 2014
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.39 KB | None | 0 0
  1. --Lightning timer
  2. --NAPTlME
  3.  
  4. rednet.open('right')
  5. p = peripheral.wrap('pim_2')
  6. mon = peripheral.wrap('monitor_7')
  7. rs.setOutput('front',false)
  8. mon.clear()
  9.  
  10. mon.setTextScale(0.5)
  11. line1 = 'Children of Lightning seek the'
  12. line2 = 'Thrills of Speed'
  13. line3 = 'They are always looking forward'
  14. line4 = 'With no time for regrets'
  15. w,h = mon.getSize()
  16. mon.setCursorPos((w/2)-(string.len(line1)/2),1)
  17. mon.write(line1)
  18. mon.setCursorPos((w/2)-(string.len(line2)/2),2)
  19. mon.write(line2)
  20. mon.setCursorPos((w/2)-(string.len(line3)/2),4)
  21. mon.write('They are always looking forward,')
  22. mon.setCursorPos((w/2)-(string.len(line4)/2),5)
  23. mon.write('With no time for regrets')
  24.  
  25. local s = 0
  26. local m = 1
  27.  
  28. function timer()
  29.   while s > 0 or m> 0 do
  30.     mon.clear()
  31.     mon.setTextScale(1.5)
  32.     w,h = mon.getSize()
  33.     mon.setCursorPos(w/2-2,2)
  34.     if m < 10 then
  35.       min = "0"..m
  36.     else
  37.       min = m
  38.     end
  39.     if s <10 then
  40.       sec = "0"..s
  41.     else
  42.       sec = s
  43.     end
  44.     mon.write(min..":"..sec)
  45.     sleep(1)
  46.     if s~= 0 then
  47.       s = s-1
  48.     else
  49.       if m ~= 0 then
  50.         s = 59
  51.         m = m-1
  52.       end
  53.     end
  54.   end
  55.   os.reboot()
  56. end
  57.  
  58.  
  59. while true do
  60.     os.pullEvent('player_on')
  61.     d = p.getAllStacks()
  62.     r = textutils.serialize(d)
  63.     if string.len(r) == 2 then
  64.       rs.setOutput('front',true)
  65.       rednet.send(452, "open")
  66.       timer()
  67.     end
  68. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement