[Mod] Timespeed [timespeed]

Post Reply
User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

[Mod] Timespeed [timespeed]

by Linuxdirk » Post

Change time speed for day/night)

If you played Minetest for some time you might notice that the night gets annoying very quick. Slaying monsters can be done underground (if a mod is installed that adds them) and lighting the surface builds is done very quick but what’s then? Minetest nights are just dark (and feels even darker if you record your gameplay), so you either need to manually set the time to day or skip the night in a bed.

Another way to get rid of nights is setting the time_speed value to 0. But that completely disables the time speed so it will never become day or night again. Plus: there might be mods depending on time changes that may become dysfunctional or will act weird if time does not change.

So, if you ever wanted to have nights being over faster or ever wanted to have longer days (or both) maybe this mod is something for you. By default the daytime speed is not changed but the nighttime speed gets changed so a night is only around 2:30 minutes long.

Information

When shutting down the server (or leaving the singleplayer world) everything gets set back to normal wich is necessary because time speed is global and this likely won’t be changed in the foreseeable future.

All of the relevant values (daytime/nighttime start and speed, 4 values in total) are tweakable via the extended configuration (or by manually adding the corresponding settings to the configuration file.)

There are multiple configuration options to be set via advanced settings within the client or directly in minetest.conf and a chat command to stop and continue the functionality on permission basis. See the mod’s README.md file for details.

Obtaining the mod

Depends: Nothing
License (everything): MIT License
Download: Latest version (always compatible with latest non-dev Minetest version)
… or better use Git: git.0x7be.net
Content Database: https://content.minetest.net/packages/Linuxdirk/timespeed/
Last edited by Linuxdirk on Sun Jul 16, 2023 19:58, edited 8 times in total.

User avatar
cx384
Member
Posts: 653
Joined: Wed Apr 23, 2014 09:38
GitHub: cx384
IRC: cx384

Re: [Mod] Timespeed [timespeed] (change timespeed for day/ni

by cx384 » Post

To make the day longer and night shorter seems unrealistic to me, but who doesn't want to get rid of the night?
So nice idea!
Can your read this?

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Timespeed [timespeed] (change timespeed for day/ni

by sorcerykid » Post

I don't think it's unrealistic. According to Wikipedia:

https://en.wikipedia.org/wiki/Daytime#D ... nd_seasons
Although the length of the daytime period is always twelve hours at the Equator, in all seasons, at all other latitudes the length varies with the season. During the winter, the daytime period is shorter than twelve hours; during the summer, it is longer than 12 hours. When it is winter north of the Equator, it is summer south of the Equator, and vice versa.
Even with that said, my primary concern is there is no way to alter the day-vs-night cycle except by constantly varying the time speed. For subgames that show a world clock in the HUD, this will look very silly since the hours and minutes will change pace as well. And that is unrealistic :P

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Timespeed [timespeed] (change timespeed for day/ni

by Linuxdirk » Post

Haha, yes, this isn’t aimed towards realism but convenience. It’s for when you play modded Minetest Game and don’t want to skip night manually or can’t disable time completely.

How realistic different time speeds for day and night are in a game where you can happily jump around while carrying 3168 cubic meters of cobblestone isn’t anything I want to judge :)
sorcerykid wrote:since the hours and minutes will change pace as well. And that is unrealistic :P
Wait a second (or minute, or hour, or whatever you want, that doesn’t matter because I am the master over time, so just wait …), are you denying time travel? :)

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Timespeed [timespeed] (change timespeed for day/ni

by sorcerykid » Post

I wonder what it would take under the hood to change the day/night cycle without modifying the world clock itself. Altho I haven't looked at the CPP network code, I imagine that immediately before the time_of_day packet is actually sent to the client, the value could be factored against a given day vs. night ratio.

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Timespeed [timespeed] (change timespeed for day/ni

by Linuxdirk » Post

sorcerykid wrote:I wonder what it would take under the hood to change the day/night cycle without modifying the world clock itself.
From what I had to code and look up It feels like the time system has to be reworked completely. What I did is nothing more than a simple hack.

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Timespeed [timespeed] (change timespeed for day/ni

by Sokomine » Post

Getting rid of the night is always welcome. Hard to harvest materials and eventually use them if all is dark. I usually plaster my creations with tons of torches.
A list of my mods can be found here.

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Timespeed [timespeed]

by sorcerykid » Post

Sokomine, it's already possible to get rid of night by setting the time_speed server variable.

Sokomine
Member
Posts: 4276
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: [Mod] Timespeed [timespeed]

by Sokomine » Post

I'm aware of that. On servers, not all players have the privileges for setting the time, and not all moderators want to change it to day all the time. If the night is automaticly shortened by a mod that's certainly good :-) My singleplayer worlds have constant mid-day. That might get a bit boring on a server and make it tricky to prepare the house for the (never coming) night.
A list of my mods can be found here.

Chem871
Member
Posts: 999
Joined: Sat Aug 19, 2017 21:49
GitHub: Chemguy99
In-game: Chem Nyx
Location: My Basement's Attic

Re: [Mod] Timespeed [timespeed]

by Chem871 » Post

Some people might want the nights to be longer than the days, so....
What is SCP-055?

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Timespeed [timespeed]

by sorcerykid » Post

Chem871 wrote:Some people might want the nights to be longer than the days, so....
Yes on my server I have seasons, and so I've long wanted to have longer nights during the winter but haven't found any way to do that without modifying the engine.

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Timespeed [timespeed]

by Linuxdirk » Post

Chem871 wrote:Some people might want the nights to be longer than the days, so....
It is of course possible with this mod. Set timespeed_nighttime_speed to 36 and the night will be twice as long as the day (normal speed is 72).

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Timespeed [timespeed]

by sorcerykid » Post

Like I said that alters the pace of the world clock, which is not really acceptable for my subgame since the time is shown in several places. Since I want some degree of realism for the day/night cycle, I need a constant timespeed :P

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Timespeed [timespeed]

by Linuxdirk » Post

sorcerykid wrote:Like I said that alters the pace of the world clock, which is not really acceptable for my subgame since the time is shown in several places. Since I want some degree of realism for the day/night cycle, I need a constant timespeed :P
“[engine change needed]”

:)

User avatar
sorcerykid
Member
Posts: 1841
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [Mod] Timespeed [timespeed]

by sorcerykid » Post

Me being curious, I checked the source code and discovered it's apparently just one line that needs to be changed :)

Code: Select all

         /*
                Send to clients at constant intervals
        */

        m_time_of_day_send_timer -= dtime;
        if(m_time_of_day_send_timer < 0.0) {
                m_time_of_day_send_timer = g_settings->getFloat("time_send_interval");
                u16 time = m_env->getTimeOfDay();
                float time_speed = g_settings->getFloat("time_speed");
                SendTimeOfDay(PEER_ID_INEXISTENT, time, time_speed);
        }
All that should be required is to alter the values of time_speed and time before sending them to the client via SendTimeOfDay( ), probably using the same algorithm that you are using in your mod. Of course a new setting would also have to be added to minetest.conf, but that part should be quite straighforward as you can see it's already reading two other related settings as well.

I might go ahead try implementing this change in my fork of the engine and seeing what happens, at least as a proof of concept :)

User avatar
bhree
Member
Posts: 169
Joined: Tue Jun 19, 2018 07:45
GitHub: bhree
IRC: bhree
In-game: bhree
Location: Alone In The Wild Land
Contact:

Re: [Mod] Timespeed [timespeed]

by bhree » Post

I'm not sure this mod has better alternative or not but I see it very interesting although unrealistic, and I think quite a game changer. I see some code and I want to make sure it's correct. It seems working on my server.

Original code:

Code: Select all

local daytime_start = setting_get('daytime_start', 4300)
local nighttime_start = setting_get('nighttime_start', 19359)
local daytime_speed = setting_get('daytime_start', 72)
local nighttime_speed = setting_get('nighttime_start', 360)
I changed to :

Code: Select all

local daytime_start = setting_get('daytime_start', 4300)
local nighttime_start = setting_get('nighttime_start', 19359)
local daytime_speed = setting_get('daytime_speed', 72)
local nighttime_speed = setting_get('nighttime_speed', 360)
The 2 last lines should be speed instead of start. Please inform if MT has implemented internal system that can change time speed.
Regards.

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Timespeed [timespeed]

by Linuxdirk » Post

bhree wrote:I'm not sure this mod has better alternative or not but I see it very interesting although unrealistic, and I think quite a game changer.
Indeed :) But you can do it the other way round, too, and have super long nights and short days. It all depends on your type of server/game. Personally I don’t want to skip nights manually by sleeping but I also don’t want to freeze the time permanently – this was the main reason for the mod.
bhree wrote:The 2 last lines should be speed instead of start.
You’re correct, thanks for pointing that out. I just fixed that so simply pull the latest changes from GitLab and your custom values in minetest.conf will be loaded properly.
bhree wrote:Please inform if MT has implemented internal system that can change time speed.
Currently no. There only is a general setting for the general speed of time that is applied to all worlds but nothing even close to this mod. See this issue and the comments to it for further details.

User avatar
bhree
Member
Posts: 169
Joined: Tue Jun 19, 2018 07:45
GitHub: bhree
IRC: bhree
In-game: bhree
Location: Alone In The Wild Land
Contact:

Re: [Mod] Timespeed [timespeed]

by bhree » Post

Personally I don’t want to skip nights manually by sleeping but I also don’t want to freeze the time permanently – this was the main reason for the mod.
when there are more than 1 player and not all of them has bed then skipping night is difficult. Very nice mod.

Teen_Miner
Member
Posts: 46
Joined: Fri Jun 03, 2016 18:21
GitHub: LapisWolf
IRC: LapisWolf
In-game: LapisWolf

Re: [Mod] Timespeed [timespeed]

by Teen_Miner » Post

How do I change the speed? (and what's supposed to be the default?) I feel like the day/night cycle is a bit too fast on my end and the default time will stay still if I have no mods(that's not supposed to happen). I just want to set it to the time speed that Minetest is supposed to have by default but I don't know how.
cdb_yuId0gpEgnYo

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Timespeed [timespeed]

by Linuxdirk » Post

Teen_Miner wrote:
Sun Jun 28, 2020 16:36
How do I change the speed?
This is set in minetest.conf. You can either set the values directly or use the advanced configuration within the client.

Daytime is unchanged (72 is the default value) and nighttime is changed to 360 (72 also is the default value here). You can also define when the speed is set.

See the mod’s settingtypes.txt for detailed description on what to set.

https://gitlab.com/4w/timespeed/-/blob/ ... gtypes.txt

You need to lower the values to make day/night longer.
Teen_Miner wrote:
Sun Jun 28, 2020 16:36
I just want to set it to the time speed that Minetest is supposed to have by default but I don't know how.
If you want the regular time speeds applied you do not need this mod. Just set time_speed = 72 in minetest.conf or remove the entry completely and do not enable this mod.

Teen_Miner
Member
Posts: 46
Joined: Fri Jun 03, 2016 18:21
GitHub: LapisWolf
IRC: LapisWolf
In-game: LapisWolf

Re: [Mod] Timespeed [timespeed]

by Teen_Miner » Post

Linuxdirk wrote:
Sun Jun 28, 2020 17:07
Teen_Miner wrote:
Sun Jun 28, 2020 16:36
How do I change the speed?
This is set in minetest.conf. You can either set the values directly or use the advanced configuration within the client.

Daytime is unchanged (72 is the default value) and nighttime is changed to 360 (72 also is the default value here). You can also define when the speed is set.

See the mod’s settingtypes.txt for detailed description on what to set.

https://gitlab.com/4w/timespeed/-/blob/ ... gtypes.txt

You need to lower the values to make day/night longer.
Teen_Miner wrote:
Sun Jun 28, 2020 16:36
I just want to set it to the time speed that Minetest is supposed to have by default but I don't know how.
If you want the regular time speeds applied you do not need this mod. Just set time_speed = 72 in minetest.conf or remove the entry completely and do not enable this mod.
Thank you. I had originally downloaded this mod because the time wasn't changing at all by default and i had never changed it, but it was fixed after i updated.
cdb_yuId0gpEgnYo

DoogMitt
Member
Posts: 20
Joined: Sat Nov 25, 2017 05:53
IRC: Doog

Re: [Mod] Timespeed [timespeed]

by DoogMitt » Post

This is an excellent mod and does the job nice a quick. Ran in to an issue with the sky jerking back and forth whenever transitioning from one speed to the other. I live in a northern lattitude, and having long days and short nights reminds me of summer. It's quite comforting, especially in winter when the nights are long with only a few hours of day.

So... This drop in script will sample time every 5 seconds then use cosine to plot the speed at which time passes. As is, the thing is set to give about 20 minutes per day and just a few minutes per night.

https://drive.google.com/file/d/1Su82ep ... sp=sharing

I do not care for recognition. Just wanted to share a skewed time script that works for me. If you like it, cool. If not, cool.

Peace

User avatar
Linuxdirk
Member
Posts: 3218
Joined: Wed Sep 17, 2014 11:21
In-game: Linuxdirk
Location: Germany
Contact:

Re: [Mod] Timespeed [timespeed]

by Linuxdirk » Post

Yeah, this is a known issue and as far as I know i t is not fixable at the moment. If your code works for you, that’s great.

While I can read your code I don’t understand what exactly it does. Naming the variables just math_a to math_h does not help much with that :) And where does the code distinguish between day time and night time? The value is just used in some of the math_... calculations.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 22 guests