Advertisement
Guest User

Untitled

a guest
Jun 27th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.81 KB | None | 0 0
  1. -- dayLength defines how long, in minutes, a day in your game is. Feel free to alter it.
  2. local dayLength = 12
  3.  
  4. local daysPassed = 0
  5.  
  6. local cycleTime = dayLength*60
  7. local minutesInADay = 24*60
  8.  
  9. local lighting = game:GetService("Lighting")
  10.  
  11. local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
  12. local endTime = startTime + cycleTime
  13.  
  14. local timeRatio = minutesInADay / cycleTime
  15.  
  16. if dayLength == 0 then
  17.     dayLength = 1
  18. end
  19.  
  20. repeat
  21.     local currentTime = tick()
  22.    
  23.     if currentTime > endTime then
  24.         startTime = endTime
  25.         endTime = startTime + cycleTime
  26.         --
  27.         daysPassed = daysPassed + 1
  28.         if daysPassed % 3 == 0 then --// every 3 days
  29.             print 'its been 3 days'
  30.         end
  31.     end
  32.    
  33.     lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
  34.     wait(1/15)
  35. until false
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement