Add rain sound. Use timer for globalstep cycle. Improve raindrop texture. Disable rainfall in deserts below savanna-desert border voronoi line. Sample light at player head position for precipitation while swimming
parent
ecf29afdfe
commit
a8644f2c29
11
README.txt
11
README.txt
|
@ -1,4 +1,11 @@
|
||||||
snowdrift 0.5.0 by paramat
|
snowdrift 0.5.0 by paramat
|
||||||
For Minetest 0.4.12 and later
|
For Minetest 0.4.15 and later
|
||||||
Depends default
|
Depends default
|
||||||
Licenses: Source code MIT. Media (textures) CC BY-SA (3.0)
|
|
||||||
|
Licenses:
|
||||||
|
Source code:
|
||||||
|
MIT by paramat
|
||||||
|
Media:
|
||||||
|
Textures CC BY-SA (3.0) by paramat
|
||||||
|
Sounds CC BY (3.0) by inchadney
|
||||||
|
http://freesound.org/people/inchadney/sounds/58835/
|
||||||
|
|
63
init.lua
63
init.lua
|
@ -1,10 +1,10 @@
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
local PRECSPR = 11 -- Time scale for precipitation variation in minutes
|
local PRECSPR = 6 -- Time scale for precipitation variation in minutes
|
||||||
local PRECOFF = 0.8 -- Precipitation noise threshold offset
|
local PRECOFF = -0.4 -- Precipitation offset, higher = rains more often
|
||||||
local PROCHA = 0.2 -- Per player per globalstep processing chance
|
local GSCYCLE = 0.5 -- Globalstep cycle (seconds)
|
||||||
local FLAKES = 8 -- Snowflake density
|
local FLAKES = 16 -- Snowflakes per cycle
|
||||||
local DROPS = 16 -- Rainfall density
|
local DROPS = 32 -- Raindrops per cycle
|
||||||
local NISVAL = 39 -- Clouds RGB value at night
|
local NISVAL = 39 -- Clouds RGB value at night
|
||||||
local DASVAL = 175 -- Clouds RGB value in daytime
|
local DASVAL = 175 -- Clouds RGB value in daytime
|
||||||
|
|
||||||
|
@ -58,17 +58,25 @@ local nobj_prec = nil
|
||||||
|
|
||||||
-- Globalstep function
|
-- Globalstep function
|
||||||
|
|
||||||
|
local handles = {}
|
||||||
|
local timer = 0
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
timer = timer + dtime
|
||||||
-- Randomise and spread processing load
|
if timer < GSCYCLE then
|
||||||
if math.random() > PROCHA then
|
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
timer = 0
|
||||||
|
|
||||||
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
|
local player_name = player:get_player_name()
|
||||||
|
|
||||||
local ppos = player:getpos()
|
local ppos = player:getpos()
|
||||||
local pposx = math.floor(ppos.x)
|
local pposx = math.floor(ppos.x)
|
||||||
local pposy = math.floor(ppos.y)
|
local pposy = math.floor(ppos.y) + 2 -- Precipitation when swimming
|
||||||
local pposz = math.floor(ppos.z)
|
local pposz = math.floor(ppos.z)
|
||||||
|
local ppos = {x = pposx, y = pposy, z = pposz}
|
||||||
|
|
||||||
local nobj_temp = nobj_temp or minetest.get_perlin(np_temp)
|
local nobj_temp = nobj_temp or minetest.get_perlin(np_temp)
|
||||||
local nobj_humid = nobj_humid or minetest.get_perlin(np_humid)
|
local nobj_humid = nobj_humid or minetest.get_perlin(np_humid)
|
||||||
|
@ -78,16 +86,22 @@ minetest.register_globalstep(function(dtime)
|
||||||
local nval_humid = nobj_humid:get2d({x = pposx, y = pposz})
|
local nval_humid = nobj_humid:get2d({x = pposx, y = pposz})
|
||||||
local nval_prec = nobj_prec:get2d({x = os.clock() / 60, y = 0})
|
local nval_prec = nobj_prec:get2d({x = os.clock() / 60, y = 0})
|
||||||
|
|
||||||
-- Biome system: frozen biomes below heat 35,
|
-- Biome system: frozen biomes below heat 35.
|
||||||
-- deserts below humidity 20
|
-- deserts below line 14 * t - 95 * h = -1496
|
||||||
|
-- h = (14 * t + 1496) / 95
|
||||||
|
-- h = 14/95 * t + 1496/95 where 1496/95 is y intersection
|
||||||
|
-- h - 14/95 t = 1496/95 y intersection
|
||||||
|
-- so area above line is
|
||||||
|
-- h - 14/95 t > 1496/95
|
||||||
local freeze = nval_temp < 35
|
local freeze = nval_temp < 35
|
||||||
local precip = nval_prec > (nval_humid - 50) / 50 + PRECOFF
|
local precip = nval_prec < (nval_humid - 50) / 50 + PRECOFF and
|
||||||
|
nval_humid - (14 / 95) * nval_temp > 1496 / 95
|
||||||
|
|
||||||
-- Check if player is outside
|
-- Check if player is outside
|
||||||
local outside = minetest.get_node_light(ppos, 0.5) == 15
|
local outside = minetest.get_node_light(ppos, 0.5) == 15
|
||||||
|
|
||||||
-- Occasionally reset player sky
|
-- Occasionally reset player sky
|
||||||
if math.random() < 0.05 then
|
if math.random() < 0.1 then
|
||||||
if precip then
|
if precip then
|
||||||
-- Set overcast sky
|
-- Set overcast sky
|
||||||
local sval
|
local sval
|
||||||
|
@ -114,6 +128,14 @@ minetest.register_globalstep(function(dtime)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not precip or not outside or freeze then
|
||||||
|
if handles[player_name] then
|
||||||
|
-- Stop sound if playing
|
||||||
|
minetest.sound_stop(handles[player_name])
|
||||||
|
handles[player_name] = nil
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
if precip and outside then
|
if precip and outside then
|
||||||
-- Precipitation
|
-- Precipitation
|
||||||
if freeze then
|
if freeze then
|
||||||
|
@ -162,6 +184,21 @@ minetest.register_globalstep(function(dtime)
|
||||||
playername = player:get_player_name()
|
playername = player:get_player_name()
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not handles[player_name] then
|
||||||
|
-- Start sound if not playing
|
||||||
|
local handle = minetest.sound_play(
|
||||||
|
"snowdrift_rain",
|
||||||
|
{
|
||||||
|
to_player = player_name,
|
||||||
|
gain = 0.2,
|
||||||
|
loop = true,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
if handle then
|
||||||
|
handles[player_name] = handle
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
69
license.txt
69
license.txt
|
@ -2,7 +2,7 @@ License of source code
|
||||||
----------------------
|
----------------------
|
||||||
|
|
||||||
The MIT License (MIT)
|
The MIT License (MIT)
|
||||||
Copyright (C) 2014-2016 paramat
|
Copyright (C) 2017 paramat
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this
|
||||||
software and associated documentation files (the "Software"), to deal in the Software
|
software and associated documentation files (the "Software"), to deal in the Software
|
||||||
|
@ -22,3 +22,70 @@ DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
For more details:
|
For more details:
|
||||||
https://opensource.org/licenses/MIT
|
https://opensource.org/licenses/MIT
|
||||||
|
|
||||||
|
|
||||||
|
License of media (textures)
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
|
||||||
|
Copyright (C) 2017 paramat
|
||||||
|
|
||||||
|
You are free to:
|
||||||
|
Share — copy and redistribute the material in any medium or format.
|
||||||
|
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||||
|
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||||
|
|
||||||
|
Under the following terms:
|
||||||
|
|
||||||
|
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||||
|
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||||
|
that suggests the licensor endorses you or your use.
|
||||||
|
|
||||||
|
ShareAlike — If you remix, transform, or build upon the material, you must distribute
|
||||||
|
your contributions under the same license as the original.
|
||||||
|
|
||||||
|
No additional restrictions — You may not apply legal terms or technological measures that
|
||||||
|
legally restrict others from doing anything the license permits.
|
||||||
|
|
||||||
|
Notices:
|
||||||
|
|
||||||
|
You do not have to comply with the license for elements of the material in the public
|
||||||
|
domain or where your use is permitted by an applicable exception or limitation.
|
||||||
|
No warranties are given. The license may not give you all of the permissions necessary
|
||||||
|
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||||
|
rights may limit how you use the material.
|
||||||
|
|
||||||
|
For more details:
|
||||||
|
http://creativecommons.org/licenses/by-sa/3.0/
|
||||||
|
|
||||||
|
|
||||||
|
License of media (sounds)
|
||||||
|
-------------------------
|
||||||
|
|
||||||
|
Attribution 3.0 Unported (CC BY 3.0)
|
||||||
|
Copyright (C) 2008 inchadney
|
||||||
|
|
||||||
|
You are free to:
|
||||||
|
Share — copy and redistribute the material in any medium or format.
|
||||||
|
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
|
||||||
|
The licensor cannot revoke these freedoms as long as you follow the license terms.
|
||||||
|
|
||||||
|
Under the following terms:
|
||||||
|
|
||||||
|
Attribution — You must give appropriate credit, provide a link to the license, and
|
||||||
|
indicate if changes were made. You may do so in any reasonable manner, but not in any way
|
||||||
|
that suggests the licensor endorses you or your use.
|
||||||
|
|
||||||
|
No additional restrictions — You may not apply legal terms or technological measures that
|
||||||
|
legally restrict others from doing anything the license permits.
|
||||||
|
|
||||||
|
Notices:
|
||||||
|
|
||||||
|
You do not have to comply with the license for elements of the material in the public
|
||||||
|
domain or where your use is permitted by an applicable exception or limitation.
|
||||||
|
No warranties are given. The license may not give you all of the permissions necessary
|
||||||
|
for your intended use. For example, other rights such as publicity, privacy, or moral
|
||||||
|
rights may limit how you use the material.
|
||||||
|
|
||||||
|
For more details:
|
||||||
|
http://creativecommons.org/licenses/by/3.0/
|
||||||
|
|
Binary file not shown.
Binary file not shown.
Before Width: | Height: | Size: 148 B After Width: | Height: | Size: 148 B |
Loading…
Reference in New Issue