Advertisement
Guest User

calendar

a guest
Jan 19th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.14 KB | None | 0 0
  1. monitor = peripheral.find("monitor")
  2.  
  3. --Alteravel
  4. local time = 10 --Update
  5. local interval = 8 --Intervalo de noites
  6.  
  7. --Nao mexer
  8. local day = 0
  9. local music = false
  10. local next = os.day()
  11.  
  12. while true do
  13.  
  14.   if day ~= os.day() then
  15.     day = os.day()
  16.    
  17.     if day >= next then
  18.       next = next + 1
  19.     end
  20.      
  21.     while next%interval ~= 0 do
  22.       next = next + 1
  23.     end
  24.  
  25.     if day%interval == 0 then
  26.       if music == false then
  27.         music = true
  28.         monitor.setBackgroundColour(colors.red)
  29.         rs.setOutput("bottom", true)
  30.         sleep(1)
  31.         rs.setOutput("bottom", false)
  32.       end
  33.     else
  34.       monitor.setBackgroundColour(colors.green)
  35.       music = false
  36.     end
  37.  
  38.     monitor.clear()
  39.     monitor.setTextScale(1)
  40.  
  41.     monitor.setCursorPos(1,1)
  42.     monitor.setTextColour(colors.white)
  43.     monitor.write("Hoje:")
  44.     monitor.setCursorPos(1,2)
  45.     monitor.write("dia " .. string.format("%i", day))
  46.  
  47.     monitor.setCursorPos(1,4)
  48.     monitor.setTextColour(colors.black)
  49.     monitor.write("Negada:")
  50.     monitor.setCursorPos(1,5)
  51.     monitor.write("dia " .. string.format("%i", next))
  52.   end
  53.  
  54.   sleep(time)
  55. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement