generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Day/Night script. WITH FOG?!

Previous Thread :: Next Thread 
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
21 May 2012 09:55 AM
I'm making a Day/Night script for games, with fog, to make it more realistic when dark, so you can't see THAT FAR ahead. It is two seperate scripts, one for Day/Night and one for Fog. For the Day/Night script itself, I have the following code.

l = game:service("Lighting")
while true do
print("Updating Time...")
wait(0.3)
l:SetMinutesAfterMidnight(l:GetMinutesAfterMidnight()+1)
end

That script is perfectly fine (I know, I know, 0.3 instead of .1 or .5 like normal) but I'm not sure if the fog will work right. Here's what I got.

while true do
wait (0.1)
if game.Lighting.MinutesAfterMidnight < 660 and game.Lighting.MinutesAfterMidnight >6720 then game.Lighting.FogEnd = 1000
else game.Lighting.FogEnd = 100000
end

I'm fairly sure that SHOULD work. Line 3 is and line 4 (if game.Lighting.Minutes... and game.Lighting.FogEnd... , those two) are all one line.

I am fairly sure that this script is wrong somehow, and I have made a gramatical error. BTW, 660 is equivalent to 6 in the morning, and 6720 is equivalent to about 6/7 in the evening. I think.

Helps for meh now?



Report Abuse
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
21 May 2012 09:58 AM
Thanks for the detailed explanation, been a long time since I've seen one of those. Just a couple of errors in your second script.

while true do
wait (0.1)
if game.Lighting.MinutesAfterMidnight < 660 and game.Lighting.MinutesAfterMidnight > 6720 then
game.Lighting.FogEnd = 1000
else
game.Lighting.FogEnd = 100000
end
end

The first one is that you forgot the space between > and 6720. Second, you need to add newlines (I'm not sure if you HAVE to add new lines there, but I think you do, better safe than sorry). Finally, you needed to add an extra end at the end of the script.

Hope it works =D

~ My RPG is in BETA: http://www.roblox.com/--place?id=80741686 ~
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
21 May 2012 10:03 AM
Ah, of course the extra end, because I used 'if' in there, forgot about dat. I did think about the extra line, and wasn't sure. That's the main thing that amde me put it up here I guess. I NEVER noticed that I messed that space e_e.

When I'm done (like, now) I'll stick it up on the FM's with some cred to you. Thanks Lego!
Report Abuse
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
21 May 2012 10:09 AM
No need for credit, it's just those silly little mistakes everybody makes =D

~ My RPG is in BETA: http://www.roblox.com/--place?id=80741686 ~
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
22 May 2012 09:23 AM
Can you just SET a sig like that lego, or do you have to write it out EVERY post?
Report Abuse
Hypha is not online. Hypha
Joined: 16 May 2012
Total Posts: 315
22 May 2012 09:27 AM
Google chrome extensions are your friend.

- Hypha - iPremiumZ Gone for a day
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
22 May 2012 10:21 AM
Minutes to Hours conversion

0 = 00:00
60 = 01:00
360 = 06:00
720 = 12:00
1439 = 23:59
Report Abuse
GradientZ is not online. GradientZ
Joined: 26 Apr 2012
Total Posts: 2173
22 May 2012 11:30 AM
@lego:

You are a great Scripting Helper.
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
24 May 2012 09:44 AM
The whole fog thing doesn't seem to work.

I think it's something to do with the minuits after midnight thing, prehaps if we shoved an equals sign in like this:

while true do
wait (0.1)
if game.Lighting.MinutesAfterMidnight =< 660 and game.Lighting.MinutesAfterMidnight => 6720 then
game.Lighting.FogEnd = 1000
else
game.Lighting.FogEnd = 100000
end
end


then it would work?
Report Abuse
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
24 May 2012 10:03 AM
while true do
wait (0.1)
if game.Lighting.MinutesAfterMidnight <= 660 and game.Lighting.MinutesAfterMidnight >= 6720 then
game.Lighting.FogEnd = 1000
else
game.Lighting.FogEnd = 100000
end
end


<= not =>

~ My RPG is in BETA: http://www.roblox.com/--place?id=80741686 ~
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
24 May 2012 01:56 PM
ah, thanks.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
24 May 2012 02:15 PM
GUYS, you can't get 6720 minutes after midnight. 23:59 ( the highest it could possibly go ) is 1439 minutes...
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
24 May 2012 03:39 PM
no, 1439 min would be 8:39 PM. However, yes, I was wrong. The highest possible would be 1639, as 11:59 PM. So 1340 would be 7:00PM
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
24 May 2012 03:43 PM
So it would be...

while true do
wait (0.1)
if game.Lighting.MinutesAfterMidnight <= 660 and game.Lighting.MinutesAfterMidnight >= 1340 then
game.Lighting.FogEnd = 1000
else
game.Lighting.FogEnd = 100000
end
end


...this then?
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
24 May 2012 03:48 PM
Or prehaps it would be GetMinutesAfterMidnight or something?
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
24 May 2012 03:57 PM
Hmmm.. nothing I do seems to work. Suggestions, folks?
Report Abuse
legokid135 is not online. legokid135
Joined: 23 Jan 2009
Total Posts: 1470
24 May 2012 03:58 PM

while true do
wait (0.1)
if game.Lighting:GetMinutesAfterMidnight() <= 660 and game.Lighting:GetMinutesAfterMidnight() >= 1340 then
game.Lighting.FogEnd = 1000
else
game.Lighting.FogEnd = 100000
end
end


~ My RPG is in BETA: http://www.roblox.com/--place?id=80741686 ~
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
25 May 2012 11:52 AM
The thing still will not work for some reason, and I don't know why. Any help?
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
25 May 2012 12:16 PM
Aha! I have it! you cannot have a number smaller than 660 yet greater than 1439! It is impossible! That is why it wouldn't work! It has to be two seperate scripts, one saying this:

while true do
if game.Lighting:GetMinutesAfterMidnight() < 660 then
game.Lighting.FogEnd = 850
else
game.Lighting.FogEnd = 100000
end
wait (0.1)
end

and one saying this:

while true do
if game.Lighting:GetMinutesAfterMidnight() > 1439 then
game.Lighting.FogEnd = 850
else
game.Lighting.FogEnd = 100000
end
wait (0.1)
end

that would work. Must it be two seperate scripts, or can it be one script with two while true do's after the other?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
25 May 2012 12:41 PM
There are 14 hours
1 hour=60
2=120
3=180
4=240
5=300
6=360
7=420
8=480
9=540
10=600
11=660
12=720
13=780
14=840
15=900
16=960
17=1020
18=1080
19=1140
20=1200
21=1260
22=1320
23=1380
24=1440

Use your brain next time... 24 multiplied by 60 (to make it minutes) is 1440
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
25 May 2012 12:43 PM
Intergration

while true do
if game.Lighting:GetMinutesAfterMidnight() < 660 then
game.Lighting.FogEnd = 850
elseif game.Lighting:GetMinutesAfterMidnight() > 1439 then
game.Lighting.FogEnd = 850
else
game.Lighting.FogEnd = 100000
end
wait (0.1)
end

and one saying this:
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
25 May 2012 12:44 PM
sorry, inefficient mistake XD

best:

while true do
if game.Lighting:GetMinutesAfterMidnight() < 660 or game.Lighting:GetMinutesAfterMidnight() > 1439 then
game.Lighting.FogEnd = 850
else
game.Lighting.FogEnd = 100000
end
wait (0.1)
en
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
25 May 2012 01:11 PM
Ah, of course.

while true do
if game.Lighting:GetMinutesAfterMidnight() < 660 or game.Lighting:GetMinutesAfterMidnight() > 1439 then
game.Lighting.FogEnd = 850
else
game.Lighting.FogEnd = 100000
end
wait (0.1)
end

out of curiosity, would it then be

while true do
if game.Lighting:GetMinutesAfterMidnight() > 1140 then
game.Lighting.FogEnd = 850
else
end
wait (0.1)
end

or

while true do
if game.Lighting:GetMinutesAfterMidnight() > 1140 then
game.Lighting.FogEnd = 850
else end
wait (0.1)
end

OR

while true do
if game.Lighting:GetMinutesAfterMidnight() > 1140 then
game.Lighting.FogEnd = 850
elseend
wait (0.1)
end

Just wonderin'.
Report Abuse
xWOWZABOYx is not online. xWOWZABOYx
Joined: 05 Aug 2010
Total Posts: 2689
25 May 2012 01:57 PM
It is done! http://www.roblox.com/Day-and-Night-script-with-Fog-item?id=81689616
Report Abuse
FrenzoBlox is not online. FrenzoBlox
Joined: 20 Dec 2011
Total Posts: 28854
25 May 2012 02:51 PM
Thats the power of scripting hep :D
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image