Unofficial update to the mod DayNightExtender. Fixed a bug and updated to the latest factorio version (0.12.2).
Type: Mod
Name: DayNightExtender 1.1.0
Description: Allows individual customisation of the length of day and/or night.
License: Use at will
Version: 1.1.0
Release: 4th August 2015
Tested-With-Factorio-Version: 0.12.2
Category: Unofficial
Tags: Free, Day, Night, Daytime, Nighttime, Daylength
To Install
Simply drag and drop DayNightExtender_1.1.0.zip into your mods folder.
To Use
The default, modded day/night length is 3x the vanilla length.
Vanilla: 3.5 minutes for day or night (7 minutes for both)
Modded: 10.5 minutes for day or night (21 minutes for both)
If you wish to change the modded values it's relatively simple:
- Either extract or open the .zip file
- Navigate to /DayNightExtender_1.1.0/control.lua
- Open with Notepad.exe or your favourite text editor
- In the first few lines you'll see something similar to the below:
require "defines"
local DAY_LENGTH_MULTIPLIER = 3 -- (integer) Controls how long daytime will be. Set to 1 for default, vanilla length (3.5 minutes).
local NIGHT_LENGTH_MULTIPLIER = 3 -- (integer) Same as above but for the night.
- Change the value after DAY_LENGTH_MULTIPLIER = (or NIGHT_LENGTH_MULTIPLIER = )
- This value should be an integer that is 1 or larger (i.e. 1,2,3,4 etc.) [Default = 3]
DAY_LENGTH_MULTIPLIER = 3
local NIGHT_LENGTH_MULTIPLIER = 1
Limitations
- Can only increase day/night length in blocks of 3.5 minutes. Unfortunately decreasing the length or finer granularity is not possible.
If you use a Clock mod, read this
If you use the same value for day as night (e.g. 5 for day and 5 for night):
Nothing will break! You're totally good to go.
If you use different values for day and night (e.g. 4 for day and 2 for night):
Nothing will really break either, however you may find your ingame clock speeding up or slowing down when it changes from day to night (or vice versa). There's no gameplay effect, just the clock may not keep constant pace.
Why this occurs:
Depending on the clock mod, daytime is defined as 6am to 6pm, while night is 6pm to 6am. Now if day was suddenly twice as long as night, it would take twice as long for the 12 hours between 6am as 6pm, as the other 12 hours.
Try for yourself, set the value for day to 0 and night to 4, start a new game and depending on the clock mod, the clock may suddenly slow down when it reaches 6pm.
If theres enough demand I could probably create or alter an existing clock mod to fix this. Pretty sure it's only a small amount of work.
1.1.0 Changes
- Updated syntax for Factorio 0.12.0
- Altered variable names and descriptions for better understanding
- Fixed extension length. Original version of mod was out by 1. I.E. setting an extension length of 1 would not increase length, despite mod description. Changed variable to a multiplier instead.
So we cannot lower/decrease the day time lower than it already is. HOWEVER I am wondering if it would be possible to do this either this in this mod or in a spinoff mod, that you or someone else might want to do with it?
If we could have days get longer for a certain amount of days and the nights would get shorter, and then nights get longer as days get shorter. This would be similar to the way year round day/night cycles work.
However my idea came from the movie Pitch Black. Imagine if there are a few suns in this planet and they show for a very long time but then when the night hits the night is pitch black like the title of the movie.
I suppose if this is not possible or if no one wants to do it, I could just make my days long and then my nights long. But it would be neat if they could be progressive back and forth, so a few long days and short nights, that then flip to long nights and short days.
This mod seems to be currently blinking a lot between day/night switching over. I do not remember it doing this in version 11 as I used it back then.
If it is the only way to get it working, is it possible to make it just go straight to night and straight to day so it skips the blinking in between stage for long time?
I was about to start updating the mod when i decided to check if it wasn't done already.
Thanks
Airat9000 wrote: and if I put in the code instead of the 3 or 2, wherein the 7 or 14 while there will be more night and day ??
If you were to enter values such as 7 or 14 you'd get a much longer day/night. You could use numbers such as 50 and it would still work!
jaxterity wrote:This mod seems to be currently blinking a lot between day/night switching over. I do not remember it doing this in version 11 as I used it back then.
If it is the only way to get it working, is it possible to make it just go straight to night and straight to day so it skips the blinking in between stage for long time?
Sorry, I'm not entirely sure what you mean. Is it the transition periods between day and night you're referring to? In all my testing I've not seen any blinking. Have you installed any graphical mods? Does it still blink if this is the only mod running? If so, any chance you could post a quick video of it on youtube? About whether it's possible for it to skip straight to day and night without the tranistion periods, it MIGHT be possible and it would definitely be quite a bit of work to seperate them out so it might be something I include at a later point.
jaxterity wrote:Greetings
So we cannot lower/decrease the day time lower than it already is. HOWEVER I am wondering if it would be possible to do this either this in this mod or in a spinoff mod, that you or someone else might want to do with it?
If we could have days get longer for a certain amount of days and the nights would get shorter, and then nights get longer as days get shorter. This would be similar to the way year round day/night cycles work.
However my idea came from the movie Pitch Black. Imagine if there are a few suns in this planet and they show for a very long time but then when the night hits the night is pitch black like the title of the movie.
I suppose if this is not possible or if no one wants to do it, I could just make my days long and then my nights long. But it would be neat if they could be progressive back and forth, so a few long days and short nights, that then flip to long nights and short days.
Hey. That's right, the current implementation of the mod cannot decrease the length of day. It SHOULD be possible to change this, I've done a little research and thought of a couple of ways of handling it. It would mean a complete rewrite of the mod however but to be honest this isn't something I'm adverse to. This current mod is just a quick update to Dark's original work and if I were to redo it completely I can think of a number of ways to improve it.
Definitely an interesting idea you've got there, and would be a great reason to fully redo the mod. My quick thoughts on details:
- Have two cycles, a main one that represents a year and a a seconday one that represents a lunar month [Note, lunar month not normal months, so each cycle is independent. Both can have a combined effect however]
- Have random events, things like eclipses etc (what other events can you think of, that only effect day/night/light levels?)
- I could also implement a custom clock that can keep track of time of day, as well as each cycles status. Had a look into clocks and it shouldn't be hard.
To be honest getting the details down is almost the hardest part, actually writing the code isn't too bad. I wouldn't want to make it too complicated and make people have to read a guide, the details would ideally be intuitive with maybe a little forewarning that if the two cycles line up in a certain way something might happen.
Now, unfortunately I'm actually in the middle of writing my thesis so can't spare any time for the next two weeks or so to code, but after that I should have plenty of free time to sink my teeth into this.
Let me know if you or anyone else comes up with any cool ideas for this, we can bounce ideas of each other and I'll let you know if it sounds feasible. I'm a beginner at modding factorio and I'm sure there's people with plenty of experience who can knock this up but it sounds like a fun project I wouldn't mind having a stab at.
Yeah I'll try to see if I can get blinking video up on Youtube and post it here. I do use the WaiTEX HD mod but that shouldn't change anything to do with this mod I believe as it just ups the textures of the game to HD.
I do use other mods like Bob's mods but that shouldn't influence the time as far as I know.
I will try it with no mods but this one. What it is, is it flickers my flashlight and the light around me when it is in the transition point between day and night/night and day. So it was extremely noticeable when I tried to make the day/night length very long like 5 or 6, or do 6 for day and 4 for night. It makes the flickering flashlight/light around character even slower blinking I guess because the transition was slower. I'll try to get videos and also test without mods other than this one though.
So after further testing the problem was solved. The issue/flickering was due to the Mo Weather mod. I put that in to see it and test it out. But apparently having that with the Day/Night extender makes it flicker a lot when it transitions between day/night. I removed Mo Weather and it works great now.
Now my days are 28 minutes and nights are 21 minutes or whatnot haha.
So after further testing the problem was solved. The issue/flickering was due to the Mo Weather mod. I put that in to see it and test it out. But apparently having that with the Day/Night extender makes it flicker a lot when it transitions between day/night. I removed Mo Weather and it works great now.
Now my days are 28 minutes and nights are 21 minutes or whatnot haha.
Both of those mods try to change time of day - they are simply not compatible with each other and you were seeing the effects.
require "defines"
local DAY_LENGTH_MULTIPLIER = 3 -- (integer) Controls how long daytime will be. Set to 1 for default, vanilla length (3.5 minutes).
local NIGHT_LENGTH_MULTIPLIER = 3 -- (integer) Same as above but for the night.
local counter
-- local freeze = game:freeze_daytime()
local freeze_state -- (boolean) Determines whether the games daytime is currently frozen => Not calling freeze more then needed.
script.on_init(function()
global.counter = global.counter or 0
counter = global.counter
global.freeze_state = (type(global.freeze_state) == "nil" ) and false or global.freeze_state
freeze_state = global.freeze_state
end)
script.on_load(function()
global.counter = global.counter or 0
counter = global.counter
global.freeze_state = (type(global.freeze_state) == "nil" ) and false or global.freeze_state
freeze_state = global.freeze_state
-- if freeze_state then
-- game:freeze_daytime()
-- end
end)
-- Removed 0.12.11 https://forums.factorio.com/forum/viewtopic.php?f=3&t=17087
-- game.on_save(function()
-- global.counter = counter
-- global.freeze_state = freeze_state
-- freeze(false)
-- end)
script.on_event(defines.events.on_tick, function(event)
local tick = event.tick
if tick % 4 == 0 then
local dt = game.daytime
local extension_multiplier = (dt > 0.75 or dt < 0.25) and DAY_LENGTH_MULTIPLIER or NIGHT_LENGTH_MULTIPLIER
if counter == 0 then
counter = 1
if freeze_state then
game.freeze_daytime(false)
freeze_state = false
end
elseif counter < extension_multiplier then
counter = counter + 1
if not freeze_state then
game.freeze_daytime(true)
freeze_state = true
end
else
counter = 0
end
end
end)
Not entirely sure what all i changed, but it doesn't error out and the day nite cycle seems to be extended with the config of '3' *shrug* I think i commented out things that aren't needed and changed other things so they work. pretty sure we don't need to freeze the game on_load since its just gonna do a freeze/unfreeze at the next tick event.
Edit: On a side note, not sure if it was the aforementioned changes or the original code, but the setting of '3' in the file actually makes the day 4 times as long, it seems to add 3 days to the cycle. Not a big problem i guess. Just figured someone might wanna know if they were trying to keep the time specific.
Confirmed, unfortunately. The version 1.1.1 causes desyncs in multiplayer (factorio version 0.12.29)
This happens with client/server on the same fast computer, so it's not a network issue.
Hey there, I heard of your mod mentioned in a let's play and would love to install it, but I can't get it to work in .13 since I don't know what I'm doing. I changed the info file but when it load it gets mad about references to "game" a nil value or something. No clue.
Would be really cool if you get around to it. Thanks!
As the original author does not seem to be around anymore, here is my unofficial version, adapted to 0.13 .
I also added a feature so that you can now switch always_day mode on/off, with other mods like timetools
binbinhfr wrote:As the original author does not seem to be around anymore, here is my unofficial version, adapted to 0.13 .
I also added a feature so that you can now switch always_day mode on/off, with other mods like timetools