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

What does the script mean? I am really confused e.e

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

game.Lighting:SetMinutesAfterMidnight(5 * 60)

What does it do? Why do I have to use : What does lighting do? What is SetMinutesAfterMidnight?

0
Did you check the roblox wiki? GoldenPhysics 474 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

First of all, game.Lighting is the Lighting service. It controls all the environmental lighting, which include the time of the day, brightness, colours of light and many other things.

The SetMinutesAfterMidnight basically means the amount of minutes that have passed from midnight in the game. So you are changing the time here.

You need to use the : because SetMinutesAfterMidnight is not a property of Lighting.

1
Correction, you do not *have to* use ':' in a method call. `object:method(arg1, arg2, arg3, ...)` is actually shorthand for `object.method(object, arg1, arg2, arg3, ...)`. However, we generally prefer using ':' when dealing with Object Oriented Programming as it is shorter and more straightforward. Link150 1355 — 8y
1
`a.b`, in Lua, means "retrieve 'b' from 'a'". Similarly, `a.b(a)` means "retrieve function 'b' from 'a' and then call it with 'a' as first argument". Link150 1355 — 8y
1
Now, what we call a "method" in Object Oriented Programming is nothing more than a simple function that is *attached* or *part of* an object. That "method" or *attached function*, when called, can then reference and modify the attached object at will. The `a:b()` form implies the attached object is `a`, which makes it more straightforward, as you can instead think of it as "call method 'b' on obje Link150 1355 — 8y
Ad
Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

Alright, I agree with the answer above somewhat however, he did not cover everything. I will tell you what that script does.

Elaboration:

The function :SetMinutesAfterMidnight()which Roblox set for Lighting goes to 0:00:00 in the TimeOfDay property of Lighting, and adds whatever you put in the parameter.

Conclusion:

game.Lighting:SetMinutesAfterMidnight(5*60);

That script above will set it to 5 o' clock because it multiplies 60 by 5 and there are 60 minutes in one hour so the hours will increase 5 times.

Reasoning:

It does this because Roblox made their TimeOfDay property in Lighting to go to 0:00:00 when it is set to midnight and they also made it to where it goes to the next hour auto-matically when you add 60 minutes to the hour. So when you multiply 60 by 5 it makes it 5 o'clock.

Here is where you can learn more about Lighting and it's functions.

Here is where you can learn more about the :SetMinutesAfterMidnight()function of Lighting.

I hope I helped and thank you for reading my answer. If you have any questions or concerns please comment below.

~~ KingLoneCat

Answer this question