should disable falling snow in deserts

This commit is contained in:
HybridDog 2015-05-01 19:37:29 +02:00
parent 46cf4e907a
commit c8c2fbd013
1 changed files with 166 additions and 162 deletions

View File

@ -40,7 +40,9 @@ near torches and lava.
--=============================================================
if snow.enable_snowfall then
if not snow.enable_snowfall then
return
end
local weather_legacy
@ -75,20 +77,31 @@ if snow.enable_snowfall then
end
end)
-- copied from meru mod
local SEEDDIFF3 = 9130 -- 9130 -- Values should match minetest mapgen desert perlin.
local OCTAVES3 = 3 -- 3
local PERSISTENCE3 = 0.5 -- 0.5
local SCALE3 = 250 -- 250
--Get snow at position.
local get_snow = function(pos)
--Legacy support.
if weather_legacy == "snow" then
local perlin1 = minetest.env:get_perlin(112,3, 0.5, 150)
if perlin1:get2d( {x=pos.x, y=pos.z} ) > 0.53 then
local perlin1 = minetest.get_perlin(112,3, 0.5, 150)
if perlin1:get2d({x=pos.x, y=pos.z}) <= 0.53 then
return false
end
-- disable falling snow in desert
local desert_perlin = minetest.get_perlin(SEEDDIFF3, OCTAVES3, PERSISTENCE3, SCALE3)
local noise3 = desert_perlin:get2d({x=x+150,y=z+50}) -- Offsets must match minetest mapgen desert perlin.
if noise3 > 0.35 then -- Smooth transition 0.35 to 0.45.
return false
end
return true
else
return false
end
else
return false
end
end
local addvectors = vector and vector.add
@ -124,16 +137,16 @@ if snow.enable_snowfall then
return data
end
local snow_fall=function (pos, player, animate)
local function snow_fall(pos, player, animate)
local ground_y = nil
for y=pos.y+10,pos.y+20,1 do
local n = minetest.env:get_node({x=pos.x,y=y,z=pos.z}).name
local n = minetest.get_node({x=pos.x,y=y,z=pos.z}).name
if n ~= "air" and n ~= "ignore" then
return
end
end
for y=pos.y+10,pos.y-15,-1 do
local n = minetest.env:get_node({x=pos.x,y=y,z=pos.z}).name
local n = minetest.get_node({x=pos.x,y=y,z=pos.z}).name
if n ~= "air" and n ~= "ignore" then
ground_y = y
break
@ -172,7 +185,7 @@ if snow.enable_snowfall then
local smaxp = addvectors(ppos, {x= 20, y=0, z= 20})
-- Make sure player is not in a cave/house...
if get_snow(ppos) and minetest.env:get_node_light(ppos, 0.5) == 15 then
if get_snow(ppos) and minetest.get_node_light(ppos, 0.5) == 15 then
local minp = addvectors(ppos, {x=-9, y=3, z=-9})
local maxp = addvectors(ppos, {x= 9, y=5, z= 9})
@ -213,15 +226,6 @@ if snow.enable_snowfall then
snow_fall(randpos(sminp, smaxp), player, true)
end
end
else
if math.random(1,5) == 4 then
snow_fall(randpos(sminp, smaxp), player, true)
end
end
end
end)
end