Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Anyone know how to create a day/night cycle, but only stays night?

Asked by 4 years ago

I've been attempting this for a while. I am making a rather "spooky" game and am trying to make a storyline to where you are in a land where the sky is "cursed" and is always night time. So basically, I've got the code somewhat set up, I'm just trying to find the right number for the minutesAfterMidnight command.

local timeOfDay = minutesAfterMidnight
minutesAfterMidnight = 1439
print("variable works") --just for debugging
while true do
    minutesAfterMidnight = minutesAfterMidnight + 1
    game.Lighting:SetMinutesAfterMidnight(minutesAfterMidnight)
    timeOfDay = minutesAfterMidnight
    wait(.1)
    print("time of day works") --also for debugging
    if timeOfDay < 361 and timeOfDay > 359 then
        minutesAfterMidnight = 1439
    end
    print("if statement works") --once again for debugging
end

Again, if someone could either help me with the code and/or find the right number for the time of day, that would be awesome.

2 answers

Log in to vote
1
Answered by 4 years ago

So basically, what you want is you want to cycle through nightime, but instead of going into daytime, you want to continue cycling through nighttime?

I would accomplish this by adding something like this to your script:

local maxTime = --Set this to whatever you decide, whatever value minutesAfterMidnight is when you stop.
local minTime = --Set this to be the beginning time of your night cycle

while true do --Add this to the existing while loop instead of creating another
print(minutesAfterMidnight) --Run the script and find when you want the cycle to stop, this should give you the exact time you want.  Use this to find the value for maxTime on your own.
do

And then basically what I would do after that is once you reach the maximum time you want, start subtracting from minutesAfterMidnight instead of adding. Then when you reach the minimum, start adding. And repeat.

0
Sorry for the late response. But anyways, thanks a bundle. And yea, I was wanting it to cycle through like normal, except when the moon goes down, and when the sun usually would come up, the moon does instead. DiamondMiner199 30 — 4y
0
Let me know if you need any additional help with this; my answer assumed you had enough knowledge to do it yourself once told how, but if you need help, I can help. invalidinvoke 134 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

you dont need a code to always have night time, u can just set the time in lighting

Answer this question