Necrotico

CC Pocket Alarm

Feb 10th, 2022 (edited)
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.65 KB | None | 0 0
  1. local speaker = peripheral.wrap("back")
  2.  
  3. local last_hour = -100.0
  4.  
  5. while true do
  6.     local current_time = os.time()
  7.     if current_time >= (last_hour + 1) or math.abs(current_time - last_hour) > 3 then
  8.         for i=1, math.floor(current_time) % 12 do
  9.             if current_time >= 12 then
  10.                 speaker.playNote("cow_bell", 1.0, math.floor(current_time) % 12)
  11.             else
  12.                 speaker.playNote("bit", 1.0, math.floor(current_time))
  13.             end
  14.             sleep(0.3)
  15.         end
  16.         last_hour = math.floor(current_time)
  17.     end
  18.     term.clear()
  19.     print("Time: " .. tostring(current_time))
  20.     sleep(1)
  21. end
  22.  
Add Comment
Please, Sign In to add comment