Guest User

Clock2

a guest
Oct 21st, 2014
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.94 KB | None | 0 0
  1. --This program can be used to create a digital clock on a monitor peripheral
  2. --The monitor must be placed to the right of the computer
  3.  
  4. print("Running clock application. Hold ctrl + T to end.")
  5. peripheral.call("right", "setTextScale", 2)
  6.  
  7. local monitor = peripheral.wrap("right")
  8.  
  9. while true do
  10.     local decimalTime = os.time()
  11.     local hours = math.floor(decimalTime)
  12.     local minutes = math.floor((decimalTime - hours) * 100 * 0.6)
  13.    
  14.     local ampm
  15.     if hours > 12 then
  16.         hours = hours - 12
  17.         ampm = "PM"
  18.     else
  19.         ampm = "AM"
  20.     end
  21.     monitor.clear()
  22.     monitor.setCursorPos(1,1)
  23.     if minutes < 10 then
  24.         monitor.write(hours..":0"..minutes.." "..ampm)
  25.     else
  26.         monitor.write(hours..":"..minutes.." "..ampm)
  27.     end
  28.     sleep(.75)
  29.  if hours >= 18 and hours <= 6 then
  30.     if minutes >= 32 and hours == 18 then
  31.       redstone.setOutput("top", true)
  32.     else
  33.       redstone.setOutput("top", true)
  34.     end
  35.  else
  36.     redstone.setOutput("top", false)
  37.  end
  38. end
Add Comment
Please, Sign In to add comment