Advertisement
largeNumberGoeshere

CC nixie clock

Mar 2nd, 2025 (edited)
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. -- requires:
  2. --  CC restitched 1.76 for minecraft 1.19.2 (fabric loader)
  3. --  "Source block" from "CC:C bridge"
  4. --  4 nixie tube blocks linked to the bridge with a "display link"
  5.  
  6.  
  7. local function fmtTime(time)
  8.     if time == 0 then
  9.         return "00"
  10.     elseif time < 10 then
  11.         return "0" .. tostring(time)
  12.     else
  13.         return tostring(time)
  14.     end
  15. end
  16.  
  17. display = peripheral.find("create_source")
  18. display.clear()
  19.  
  20. while true do
  21.     local time = os.time("utc")
  22.    
  23.     -- chatgpt slop,,, but it works
  24.     local hours = math.floor(time)
  25.     local mins = math.floor((time - hours) * 60)
  26.     local secs = math.floor(((time - hours) * 60 - mins) * 60)
  27.     local tenths = math.floor((((time - hours) * 60 - mins) * 60 - secs) * 10)
  28.    
  29.     display.clear()
  30.     display.setCursorPos(1,1)   -- source blocks do not do line wrapping etc
  31.     display.write(fmtTime(hours))
  32.     display.write(":")
  33.     display.write(fmtTime(mins))
  34.     display.write(":")
  35.     display.write(fmtTime(secs))
  36.     sleep(0.1)
  37. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement