PDA

View Full Version : [Lua] Time



LJ Sonic
June 23rd, 2014, 17:06
703970407041

This is a 24 hours-based timing system with progressive night and day.
It also provides random weather changes, which include rain, snow and storms.

You have a digital clock in the bottom-right corner of the screen that can be shown / hidden by turning the clock variable on / off.

If you can't play because of the darkness, you can skip the night by using the sleep command in the console, so the time will pass faster until you use the wakeup command. You have to set allowsleep on to sleep in a netgame.
You can neither move or see while sleeping, so make sure ennemies won't reach you. The clock is still visible, so you can know when this is morning.
Note that you can also sleep during daytime, and that in netgames the time will only speed up if every player (aside from spectators or dead players) is sleeping.

Console commands:


"sleep": Start sleeping. In netgame it needs allowsleep on.
"wakeup": Stop sleeping. In netgame it needs allowsleep on.
"time": Displays the current time in the console.
"changetime <hours> [minutes] [seconds]" (server / admin only): Setup the time. If minutes or seconds aren't specified, they default to 0.
"timehelp": Lists all commands and variables in this script.


Console variables:


"enablelightchange" (server / admin only): Actives or desactives the brightness changing. "Auto" will active or desactive it depending on the level.
"clock": Shows / hides the clock HUD.
"notifytime": Display a message on hour change.
"timefactor" (server / admin only): How many times faster is the time compared to reality ? (default is 60, which means 1 second = 1 minute IRL).
"nighttimefactor" (server / admin only): How many times faster the time passes while sleeping. (default is 16)
"daylight" (server / admin only): The brightness level during the day. 255 means it'll keep the same lightning as day, 0 means it'll be fully dark. (default is 255)
"nightlight" (server / admin only): The brightness level during the night. 255 means it'll keep the same lightning as day, 0 means it'll be fully dark. (default is 128)
"daysky" (server / admin only): The sky number used during the day. 0 will keep the normal sky of the level. (default is 0)
"nightsky" (server / admin only): The sky number used during the night. (default is 21)
"morningsky" (server / admin only): The sky number used during the morning.
"eveningsky" (server / admin only): The sky number used during the evening.
"allowsleep" (server / admin only): Allows players to sleep in a netgame.
"randomweather" (server / admin only): Actives or desactives the weather changing. You can also specify one of the following values to disable some types of weather:



-"Rain" will only enable rain and storms.
-"Snow" will only enable snow.
-"Thunder" will only enable thunders with no rain.
-"NoThunder" will disable thunders.
-"NoRain" will disable rain.
-"RainNoThunder" will only enable rain with no thunders.





"randomweatherfactor" (server / admin only): The frequency of weather changes, in percents. Lowering it will make the weather more stable, raising it will make the weather changing more often. 100% is the default frequency.

These are in beta stage, but still working (it won't break the script):


"energy" (server / admin only): active or desactive the energy system.
"maxenergy" (server / admin only): Maximum amount of energy, in minutes.


Credits:
Thanks to speed2411 (http://mb.srb2.org/member.php?u=5124) for the morning and evening skies !

Colby
June 23rd, 2014, 21:10
Simply amazing, this is very fun to use for many scenarios, and helps for making maps too.

LJ Sonic
June 23rd, 2014, 22:09
Making maps ?

Colby
June 23rd, 2014, 23:00
Less fofs to deal with to make that same thing happen like in SF94 (though I just add the Lua separately so I don't have to ask you for permission every time I want to use it with a map I am making/testing). Also, may I request a possible afternoon sky? I know making color maps with Lua is tough, but maybe just the sky change only would do well? Going from a blue sky to a black one slightly throws me off unless I am indoors.

LJ Sonic
June 25th, 2014, 19:07
Ho feel free to use this script as much as you want, and even modify it, this is one of the reason what this script was made for. You don't need to wait for my permission, just put it in credits if you release it. Same for everyone else.

And yeah, about the sky, I totally agree, I first planned to do that, but I didn't find an adapted sky for twilight, and I wanted the file to be very small, so I couldn't add a sky texture. I think I'll make an expanded version of this mod with transition sky (or skies ?).

By the way, I forgot mentionning that brightness was lowering from 18:00 to 22:00, and raising from 6:00 to 10:00.

Ho, and I have to mention that this script will interfere with other lightning effects (not colormaps hopefully), unless you manually adapt the script to handle them.

- - - - - - - - - -

Updated !
- I added a daylight variable.
- I added morning and evening skies, although they're not really adapted...
- I added an exception list at the second line of the script. Every map number here won't be affected by the script unless you set enablelightchange on.
- I fixed the clock that was getting mad with ridiculously big time factor.

Fennekin
June 29th, 2014, 19:12
Nice. I know you wanted me to visit this, so here I am.
I'm gonna give this a reason to exist by saying...it's good? Yeah, it's pretty cool to see day and night.

LJ Sonic
November 9th, 2014, 19:49
Welcome to the Skybase Firework ! I just wanted to give you some tip for starting srb2, it's okay if you don't download my wad, I just answered because you asked me where you could find it XD

- - - - - - - - - -

The script has been updated ! Changes:


Fixed a bug that would make late joiners having the lightning system broken until map is reloaded or changed.
Added an allowsleep variable that can disable the sleep and wakeup commands, so you can avoid problems if they are causing resynch. It doesn't affect Single Player.
Thanks to 2.1.11, the day sky is now the one used normally in the level. You can still change it by setting the daysky to another value than zero.
The maxenergy variable is now expressed in minutes rather than tics, so you can easily choose how many time players can wait before sleeping.
Added a timehelp command that lists all commands and variables available.
Also, there is no more an "advanced" version and a "light" version of the script, there is a unique download instead.


- - - - - - - - - -

The script has been updated ! Changes:


Added a random weather change system.
Added randomweather and randomweatherfactor variables to handle the new weather system (read the description).
Added three exceptions lists for levels where rain, snow or storms aren't meant to happend. These lists are similar to the one used for the brightness level, and you can change them the same way than it.
Added Desolate Twilight Zone to the unaffected levels list.


- - - - - - - - - -

The script has been updated ! Changes:


Changed the night sky number to 8.
Deeply modified the way datas synchronization was handled during netgames. Now the script can actually handle dedicated servers very well.
If you add this file during a netgame, you now have to reload the level or switch to another map for the script to work. Note that it should have fixed the crash on file adding.

Xader
April 8th, 2015, 00:20
Amazing, this is very fun like the real its good and cool to see day and night,thunder and rain.

LJ Sonic
April 11th, 2015, 11:21
Glad you like it, although be aware I am no more updating this wad on the Skybase, so if you want the very last version you can only get it from the srb2mb.