theFox6/minetest_mod_weather

Underground weather

Opened this issue · 3 comments

orbea commented

Describe the bug

Underground weather is not entirely fixed when in a large enough open spaces.

The weather effects will constantly start and stop which is not only silly, but highly distracting.

To Reproduce

  1. Dig until finding a large enough open cavern or make your own.
  2. Start some weather.
  3. There will be weather when there is no sky access.

Expected behavior
It would be nice if weather was disabled when there is no sky access or if there is sky access the weather particles would be restricted to to only nodes that had sky access.

Screenshots
rain

Desktop (please complete the following information):

  • Minetest version: 5.2.0

Additional context
I tried this to solve the problem, but it feels incomplete.

local manip = minetest.get_voxel_manip()
local e1, e2 = manip:read_from_map(minp, maxp)
local area = VoxelArea:new{MinEdge=e1, MaxEdge=e2}
local data = manip:get_light_data()

local node_num = 0
local light = false

for i in area:iterp(minp, maxp) do
    node_num = node_num + 1
    if node_num < 5 then
        if data[i] and data[i] == 15 then
            light = true
            break
        end
    else
        node_num = 0
    end
end

if not light then return end

The remaining problem is that if the there is any sky access there will be weather everywhere in the near vicinity of the sky access and not only under the open space. Maybe there is a way to recreate the minp/maxp values with only positions that have enough light?

I know this problem...
I think one simple solution could be assuming that no weather goes below -200 nodes. That way weather could be disabled in caves.
Also I do like your solution and maybe that is good enough. I will consider adding it.

orbea commented

I'm not fond of the simple solution of disabling all weather below -200 nodes, I have experienced this at above sea level in a hollowed out mountain as well.

I have added your sky access check in 4287714.
Maybe I will improve it to fit better to different types of weather later.