Advertisement
BruceWplays

CCTimeV5

Sep 14th, 2022 (edited)
557
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.04 KB | None | 0 0
  1. month = {
  2.     {mname = "January", mlanth = 31},
  3.     {mname = "February", mlanth = 28},
  4.     {mname = "March", mlanth = 31},
  5.     {mname = "April", mlanth = 30},
  6.     {mname = "May", mlanth = 31},
  7.     {mname = "June", mlanth = 30},
  8.     {mname = "July", mlanth = 31},
  9.     {mname = "August", mlanth = 31},
  10.     {mname = "September", mlanth = 30},
  11.     {mname = "October", mlanth = 31},
  12.     {mname = "November", mlanth = 30},
  13.     {mname = "December", mlanth = 31}
  14. }
  15. curmlanth = 0
  16. while true do
  17.     lockmo = 0
  18.     --local monitor = peripheral.wrap("top")
  19.     --monitor.setTextScale(1)
  20.     local maxW, maxH = term.getSize()
  21.     local nyear = 0
  22.     term.clear()
  23.     term.setCursorPos(1,1)
  24.     local nTime = os.time()
  25.     local time_nospace_zero = string.gsub(textutils.formatTime(os.time(), false), " ", " ")  
  26.     local time_nospace_10error = string.gsub(time_nospace_zero, "0:", "12:")
  27.     nTime = string.gsub(time_nospace_10error, "112:", "10:")
  28.     local nDay = os.day()
  29.     local ognday = nDay
  30.     while nDay > 365 do
  31.         nDay = nDay - 365
  32.         nyear = nyear + 1
  33.     end
  34.     lockmday = 0
  35.     local mDay = nDay
  36.     local prevmDay = 0
  37.     curmlanth = 0
  38.     for i=1,#month do
  39.         cordaycnt = 0
  40.         prevmlanth = curmlanth
  41.         curmlanth = curmlanth + month[i].mlanth
  42.         if nDay < curmlanth then
  43.             cordaycnt = cordaycnt + 1
  44.             if nDay > prevmlanth then
  45.                 cordaycnt = cordaycnt + 1
  46.                 lockmday = 1
  47.                 --mDay = mDay + month[i].mlanth
  48.                 prevmDay = mDay
  49.                 curmonth = i
  50.                 break
  51.             end
  52.         end
  53.         if cordaycnt < 5 then
  54.             if lockmday == 0 then
  55.                 mDay = mDay - month[i].mlanth
  56.                 prevmDay = mDay
  57.             end
  58.         end
  59.         --if mDay < 1 then
  60.         --    mDay = mDay + month[i].mlanth
  61.         --    prevmDay = mDay
  62.         --end
  63.         --if mDay > month[i].mlanth then
  64.         --    mDay = mDay - month[i].mlanth
  65.         --    prevmDay = mDay
  66.         --end
  67.         --if mDay < prevmDay then
  68.         --    curmonth = curmonth + 1
  69.         --end
  70.         lockmday = 0
  71.     end
  72.  
  73.     --if mDay > month[curmonth].mlanth then
  74.     --    mDay = mDay - month[curmonth].mlanth
  75.     --    prevmDay = mDay
  76.     --end
  77.     term.setCursorPos(1, maxH)
  78.     if ognday < 10000 then
  79.         print("(" .. "Total Days: "..ognday.. ")")
  80.     elseif ognday > 9999 then
  81.         print("(" .. "TotalDays: "..ognday.. ")")
  82.     elseif ognday > 99999 then
  83.         print("(" .. "TotalDays:"..ognday.. ")")
  84.     elseif ognday > 999999 then
  85.         print("(" .. "TtlDs:"..ognday.. ")")
  86.     end
  87.     term.scroll(-1)
  88.     term.setCursorPos(1,1)
  89.     print(nTime)
  90.     term.setCursorPos(1,2)
  91.     print(mDay.." "..month[curmonth].mname)
  92.     term.setCursorPos(1,3)
  93.     print("Year " .. nyear)
  94.     local ndaylc = string.len("Day " .. nDay)
  95.     ndaylc = ndaylc - 1
  96.     term.setCursorPos(maxW - ndaylc,3)
  97.     print("Day " .. nDay)
  98.     local mineminute = 60 / 72
  99.     sleep(mineminute)
  100.     end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement