darker nights for all players

Post Reply
User avatar
uwu666
Member
Posts: 45
Joined: Mon May 04, 2020 05:20
Location: Latinoamerica

darker nights for all players

by uwu666 » Post

hi, is there a way to make nights darker for all players on server?
with some friends we have a survival and pvp server, and we would like to make the nights darker so that, together with the illumination mod, players are forced to use torches to walk in the dark and thus be more vulnerable to being detected by other players.
cdb_71b6f99a808c

User avatar
Krock
Developer
Posts: 4649
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: darker nights for all players

by Krock » Post

I found your opponent. https://irc.minetest.net/minetest/2021-04-28#i_5815708

The server should have no control about client-side settings. If brightness is an issue, change the sky to pitch black and the node textures as well.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

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

Re: darker nights for all players

by Linuxdirk » Post

Krock wrote:
Wed Apr 28, 2021 19:35
The server should have no control about client-side settings.
While it technically might be: Is lighting really something that should belong to the client?

For server owners creating the perfect world for people to explore changing brightness of the night (and day) should be possible.

User avatar
Hume2
Member
Posts: 709
Joined: Tue Jun 19, 2018 08:24
GitHub: Hume2
In-game: Hume2
Location: Czech Republic

Re: darker nights for all players

by Hume2 » Post

If lighting is supposed to belong to the client only, then everyone turns the brightness to maximum, so torches become completely useless.

On the other hand, notice that lighting can be easily overriden by a hacked client. All mapblocks are sent to the client regardless of whether they are lit or not. So it is relatively easy to write a hack which makes you see perfectly in dark.
If you lack the reality, go on a trip or find a job.

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

Re: darker nights for all players

by Linuxdirk » Post

Hume2 wrote:
Thu Apr 29, 2021 07:08
On the other hand, notice that lighting can be easily overriden by a hacked client.
A hacked client isn't even needed here. You can always set your operating system's gamma value to whatever you want without the server owner can do anything against it. Except: when the server owner can lower brightness on server-side so there is one color only so gamma does not work because there are no color differences. Nodes in complete darkness should not be transferred to the client, of course.

But it's not about making life a tad harder for cheaters, it's about creating a consistent and interesting experience to legitimate players.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: darker nights for all players

by Termos » Post

uwu666 wrote:
Mon Apr 26, 2021 23:03
hi, is there a way to make nights darker for all players on server?
it's override_day_night_ratio()

Here's my try: https://github.com/TheTermos/islands/bl ... eather.lua
See how it works here
Krock wrote:
Wed Apr 28, 2021 19:35
I found your opponent. https://irc.minetest.net/minetest/2021-04-28#i_5815708
Both want about the same thing - control over the setting.

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

Re: darker nights for all players

by Linuxdirk » Post

Termos wrote:
Thu Apr 29, 2021 08:24
it's override_day_night_ratio()
According to the Lua API documentation it controls the ratio between night and day, basically shifting sunrise and sunset to different times of the day. As far as I understand this has nothing to do with the brightness of the night.

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: darker nights for all players

by Termos » Post

Linuxdirk wrote:
Thu Apr 29, 2021 09:51
According to the Lua API documentation it controls the ratio between night and day, basically shifting sunrise and sunset to different times of the day. As far as I understand this has nothing to do with the brightness of the night.
That's not how it works, and the docs don't seem to say that.

Code: Select all

* `override_day_night_ratio(ratio or nil)`
    * `0`...`1`: Overrides day-night ratio, controlling sunlight to a specific
      amount.
1 is full daylight, 0 is pitch black, that's it.

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

Re: darker nights for all players

by Linuxdirk » Post

Termos wrote:
Thu Apr 29, 2021 10:55
1 is full daylight, 0 is pitch black, that's it.
Can't test right now, but according to the meaning of the word "ratio" I highly doubt that you can change the minimum/maximum light level of the night with that.

Edit: Just tested, and yes, setting 0 makes it extremely dark. Awesome. So the function name is just plain wrong.

Nice find btw. :)

To use it a mod could run every X seconds and check the time of the day and when it’s above/below a certain value it could iterate over all players and set the “ratio” to the desired value to make the night darker or reset it for the day.

wsor4035
Member
Posts: 182
Joined: Sun Aug 11, 2019 21:23
GitHub: wsor4035
IRC: wsor
In-game: wsor

Re: darker nights for all players

by wsor4035 » Post

yes, this how https://github.com/xenonca/ptime does it. very helpful mod for creative servers
j5uBLfc6NxgersvVj5D5dIsiKDkoQb0o

User avatar
uwu666
Member
Posts: 45
Joined: Mon May 04, 2020 05:20
Location: Latinoamerica

Re: darker nights for all players

by uwu666 » Post

Termos wrote:
Thu Apr 29, 2021 08:24

it's override_day_night_ratio()
thanks! I'll try it :)
cdb_71b6f99a808c

User avatar
uwu666
Member
Posts: 45
Joined: Mon May 04, 2020 05:20
Location: Latinoamerica

Re: darker nights for all players

by uwu666 » Post

I finally left it like this and it looked pretty good, I based it on the source code of the Islands mod to do this.

Islands mod by Termos: https://github.com/TheTermos/islands/bl ... eather.lua

Thanks :)

Code: Select all

-- Hacer que las noches sean mas oscuras
darkernight = 0

local function get_adjusted_light(atime)
	atime = atime or minetest.get_timeofday()

  -- 24 horas es igual a un entero, 0 = media noche, 0.5 = medio dia

  if atime > 0.1875 and atime < 0.8125 then -- Si cumple, la ilumincion estara por defecto (muy brillante)
  --          04:30              19:30
    return nil
  elseif atime > 0.1840 and atime < 0.8160 then
  --              04:25              19:35
    return 0.15
  elseif atime > 0.1805 and atime < 0.8195 then
  --              04:20              19:40
    return 0.1
  elseif atime > 0.1770 and atime < 0.8230 then
  --              04:15              19:45
    return 0.05
  else
    return 0 -- si ninguna de las anteriores se cumple llegara la oscuridad casi total, durara entre 19:45 y 04:15
  end
end
minetest.register_on_joinplayer(function(plyr)
    plyr:override_day_night_ratio(get_adjusted_light())
end)

minetest.register_globalstep(function(dtime)
    darkernight = darkernight + dtime
    if darkernight > 3 then
      darkernight = 0

      local curtime = minetest.get_timeofday()
      local prefs = minetest.get_connected_players()
      for _,plyr in ipairs(prefs) do
        plyr:override_day_night_ratio(get_adjusted_light(curtime))
      end
    end
end)
cdb_71b6f99a808c

cy
Member
Posts: 66
Joined: Sun Jun 24, 2012 17:25

Re: darker nights for all players

by cy » Post

It does require clients to play along, if you want them "forced to use torches to walk in the dark" but if your players are looking for that experience, then they won't turn up the brightness settings. Just make sure you're playing with good people, and everyone will either keep things dark, or they won't take advantage of other players if they can see at night. People actually do enjoy the excitement of dying in the darkness after losing their only torch, especially when they can share the video of them panicking afterwards.

AmyMoriyama
Member
Posts: 107
Joined: Wed Jun 30, 2021 14:53
GitHub: AmyMoriyama

Re: darker nights for all players

by AmyMoriyama » Post

I already can't see anything in minetest night, even with a torch and the mod to make it light the way. I am one to jack up my gamma so I can see something instead of an endless void.

That being said, there is no way to stop players from seeing in the dark if they are determined enough.

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

Re: darker nights for all players

by Linuxdirk » Post

GayJesus wrote:
Tue Jul 06, 2021 16:57
gamma doesn't work
Yes, when there are no color differences changing gamma won’t help. But since the client gets all nodes a modified client could simply display them anyways without the darkness.

The client can do whatever the client wants with the data the server sends it without the server owner being able to stop the client. The only way preventing the client using the data is not sending the data which is basically impossible right now.

But modified clients should not be considered when creating a server experience otherwise there is no reason in setting up a server.

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests