Scripts / Free Day/Night Script

Author
Message
MrEaKing(YT)
7
Years of Service
User Offline
Joined: 9th Mar 2017
Location: Ontario
Posted: 22nd Mar 2017 17:56
Hey hope this helps you all. and hope this posts correctly. first script so you may want to trim down on things or rewrite but it works. oh starts only at 8pm to start at other times change hour and minutes then change starting variables to how it would look in game (go in game press tab set it to where you want to start find the values for Fog colours, Ambience Intensity, Surface Intensity, and Surface colours write them down then add around 20 to each lol seems those numbers don't directly correspond with the coding then change the starting variables FG= fog green SB = surface Blue SI =surface intensity) hope that clears up any confusion.
[quote="

--Created by: Mr. EA King www.Youtube.com/mreaking
--set the hour and minutes to start at
local HourOfDay = 20
local MinuteOfDay = 0
-- timer variables
local TimePassed = 0
local TimeStamp = 0
local Time1 = 0
local Time2 = 0
local MinuteLength = .003 -- change to 1 to make 1 sec = 1 minute.
-- Fog colour, Ambience intensity and Surface variables
local FR = 40
local FG = 40
local FB = 40
local AmbI = 55
local SI = 35
local SR = 40
local SG = 40
local SB = 40
--init
function daynightcycle_init(e)
end

function daynightcycle_main(e)

--displays prompt checks if its AM
if HourOfDay <=12 then
if MinuteOfDay <= 9 then
Prompt ("time is " .. HourOfDay .. ":0".. MinuteOfDay .. " AM")
end
if MinuteOfDay >= 10 then
Prompt ("time is " .. HourOfDay .. ":".. MinuteOfDay .. " AM")
end
end
--displays prompt checks if its PM
if HourOfDay >=13 then
if MinuteOfDay <= 9 then
Prompt ("time is " .. HourOfDay - 12 .. ":0".. MinuteOfDay .. " PM")
end
if MinuteOfDay >= 10 then
Prompt ("time is " .. HourOfDay - 12 .. ":".. MinuteOfDay .. " PM")
end
end

--Time
if TimeStamp == 0 then
Time1 = g_Time
TimeStamp = 1
end
Time2 = g_Time
TimePassed = (Time2 - Time1) * 0.001
if TimePassed >= MinuteLength then
MinuteOfDay = MinuteOfDay + 1
if MinuteOfDay == 60 then
HourOfDay = HourOfDay + 1
--add the hour
if HourOfDay == 24 then
-- is th day done reset hours
HourOfDay = 1
end
--reset minutes
MinuteOfDay = 0
end
--time checkers
-- see what hour it is and change the variables accordingly to get sunsets/rises
--reset fog to white brighten and darken scene
if HourOfDay >= 20 then
FR = FR - .032
FG = FG - .032
FB = FB - .032
AmbI = AmbI - .06
SI = SI - .0165
SR = SR - .0165
SG = SG - .0165
SB = SB - .0165
end
if HourOfDay <= 3 then
FR = FR + .032
FG = FG + .032
FB = FB + .032
AmbI = AmbI + .0165
SI = SI + .0165
SR = SR + .0165
SG = SG + .0165
SB = SB + .0165
end
if HourOfDay == 4 or HourOfDay == 5 then
FR = FR + .18
FG = FG + .09
FB = FB + .03
AmbI = AmbI + .04
SI = SI + .0165
SR = SR + .165
SG = SG + .082
SB = SB + .0165
end
if HourOfDay == 6 or HourOfDay == 7 then
FR = FR + .03
FG = FG + .09
FB = FB + .18
AmbI = AmbI + .04
SI = SI + .0165
SR = SR + .165
SG = SG + .082
SB = SB + .0165
end
if HourOfDay == 8 or HourOfDay == 9 then
FR = FR + .032
FG = FG + .032
FB = FB + .032
AmbI = AmbI + .0165
SI = SI + .0165
SR = SR + .0165
SG = SG + .0165
SB = SB + .0165
end
if HourOfDay >= 10 and HourOfDay <= 13 then
FR = FR
FG = FG
FB = FB
AmbI = AmbI
SI = SI
SR = SR
SG = SG
SB = SB
end
if HourOfDay >= 14 and HourOfDay <= 16 then
FR = FR - .032
FG = FG - .032
FB = FB - .032
AmbI = AmbI - .0165
SI = SI - .0165
SR = SR - .0165
SG = SG - .0165
SB = SB - .0165
end
if HourOfDay == 17 or HourOfDay == 18then
FR = FR - .03
FG = FG - .09
FB = FB - .18
AmbI = AmbI - .0165
SI = SI - .0165
SR = SR - .0165
SG = SG - .0165
SB = SB - .0165
end
if HourOfDay == 19 then
FR = FR - .3
FG = FG - .18
FB = FB
AmbI = AmbI - .0165
SI = SI - .0165
SR = SR - .0165
SG = SG - .0165
SB = SB - .0165
end
SetFogRed(FR)
SetFogGreen(FG)
SetFogBlue(FB)
SetAmbienceIntensity(AmbI)
SetSurfaceIntensity(SI)
SetSurfaceRed(SR)
SetSurfaceGreen(SG)
SetSurfaceBlue(SB)
TimeStamp = 0;

end
end
"]

[video=https://youtu.be/T44ilKyqVsY]
MrEaKing(YT)
7
Years of Service
User Offline
Joined: 9th Mar 2017
Location: Ontario
Posted: 22nd Mar 2017 18:03 Edited at: 22nd Mar 2017 18:40
oh lol attach to random non-static entity
MrEaKing(YT)
7
Years of Service
User Offline
Joined: 9th Mar 2017
Location: Ontario
Posted: 22nd Mar 2017 18:10 Edited at: 22nd Mar 2017 18:39
just realised could upload the file attach to random non-static entity ex. teapot then make it always active. thx small g

Attachments

Login to view attachments
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 22nd Mar 2017 18:29
scripts go to non-static items (static = no), i'm sure you know this but you'll confuse users by telling them to attach it to a static entity
lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
lotgd
3D Media Maker
14
Years of Service
User Offline
Joined: 2nd Apr 2010
Location: italy
Posted: 22nd Mar 2017 18:34
thanks for the great job!

My Pc Specs : Win10pro64bit /Msi z97 / i74770k / gtx1070 / 16gb ram / SSD 850Evo

Login to post a reply

Server time is: 2024-04-27 02:09:07
Your offset time is: 2024-04-27 02:09:07