Temp/humidity and snow mod modes. Snow and rain independant and optional
parent
ba01303362
commit
807c41dfa5
29
README.txt
29
README.txt
|
@ -1,29 +1,4 @@
|
||||||
Snowdrift 0.2.0 by paramat
|
Snowdrift 0.2.1 by paramat
|
||||||
For latest stable Minetest and back to 0.4.6
|
For latest stable Minetest and back to 0.4.6
|
||||||
Depends default
|
Depends default
|
||||||
Licenses: code WTFPL, textures CC BY-SA
|
Licenses: code WTFPL, textures CC BY-SA
|
||||||
|
|
||||||
Version 0.1.0
|
|
||||||
---------------
|
|
||||||
* Snowfall only in the snow biomes of snow mod by Splizard. You will need to disable snow mod snowfall.
|
|
||||||
* Minimal processing for less powerful computers.
|
|
||||||
* Snowfall is only seen by a player if the player is outside under open sky.
|
|
||||||
* Each snowflake has it's own random trajectory, initial position, initial velocity and acceleration.
|
|
||||||
* Snow falls at an average of 1m/s.
|
|
||||||
* Snow drifts southwards at an average of 1m/s, a slightly lower speed than the southward cloud drift.
|
|
||||||
* Snowflakes are sized to match 16x16 texture resolution and the icons used in my texture pack.
|
|
||||||
* The snow box around the player is 128x128x32 nodes in size.
|
|
||||||
* Parameter PROCHA controls snow density and processing load, default is 0.5, try 1 for denser snow.
|
|
||||||
|
|
||||||
Version 0.1.1
|
|
||||||
-------------
|
|
||||||
* Mod is too light, doubled maximum snow density, added second snowflake design with a square symmetry.
|
|
||||||
* Snow density is now smoothly varied by how deep into a snow biome a player is.
|
|
||||||
|
|
||||||
Version 0.1.2
|
|
||||||
-------------
|
|
||||||
* Maximum snowfall doubled, 4 snowflake designs.
|
|
||||||
|
|
||||||
v0.2.0
|
|
||||||
------
|
|
||||||
* Rain defined by a second perlin noise and threshold.
|
|
185
init.lua
185
init.lua
|
@ -1,25 +1,30 @@
|
||||||
-- Snowdrift 0.2.0 by paramat
|
-- snowdrift 0.2.1 by paramat
|
||||||
-- For latest stable Minetest and back to 0.4.6
|
-- For latest stable Minetest and back to 0.4.6
|
||||||
-- Depends default
|
-- Depends default
|
||||||
-- Licenses: Code WTFPL. Textures CC BY-SA.
|
-- Licenses: code WTFPL, textures CC BY-SA
|
||||||
-- This is intended to be used as alternative snowfall for the snow mod by Splizard.
|
|
||||||
-- The code is partly derived from weather mod by Jeija and snow mod version 1.8 by Splizard.
|
|
||||||
|
|
||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
local PROCHA = 0.5 -- (0 to 1) -- Processing chance
|
local PROCHA = 0.2 -- (0 to 1) -- Per player processing chance, randomizes and spreads processing load
|
||||||
|
local DROPS = 8 -- Rainfall heaviness
|
||||||
|
local SNOWV6 = true -- Snowfall in snow biomes of snow mod by Splizard
|
||||||
|
local RAIN = false -- Rain above humidity threshold
|
||||||
|
local THOVER = false -- Instea use a temperature and humidity system with
|
||||||
|
-- snow in overlap of cold and humid
|
||||||
|
-- else rain in humid areas
|
||||||
|
local SEEDT = 112 -- 112 -- If THOVER = true, set these to your mapgen's temperature noise parameters
|
||||||
|
local OCTAT = 3 -- 3
|
||||||
|
local PERST = 0.5 -- 0.5
|
||||||
|
local SCALT = 150 -- 150
|
||||||
|
|
||||||
local SEEDS = 112 -- 112 -- Snow mod default biome noise parameters
|
local TET = -0.53 -- -0.53 -- Temperature threshold for snow
|
||||||
local OCTAS = 3 -- 3
|
-- If SNOWV6 = true set to -0.53
|
||||||
local PERSS = 0.5 -- 0.5
|
local SEEDH = 72384 -- 72384 -- Set these to your mapgen's humidity noise parameters
|
||||||
local SCALS = 64 -- 150
|
local OCTAH = 4 -- 4
|
||||||
local SNOWT = 0.4 -- 0.53
|
local PERSH = 0.66 -- 0.66
|
||||||
|
local SCALH = 500 -- 500
|
||||||
|
|
||||||
local SEEDR = -90000667
|
local HUT = 0.5 -- 0.5 -- Humidity threshold for rain
|
||||||
local OCTAR = 3
|
|
||||||
local PERSR = 0.5
|
|
||||||
local SCALR = 64
|
|
||||||
local RAINT = 0.4
|
|
||||||
|
|
||||||
-- Stuff
|
-- Stuff
|
||||||
|
|
||||||
|
@ -28,77 +33,105 @@ snowdrift = {}
|
||||||
-- Globalstep function
|
-- Globalstep function
|
||||||
|
|
||||||
minetest.register_globalstep(function(dtime)
|
minetest.register_globalstep(function(dtime)
|
||||||
-- if not raining at this time then return
|
-- TODO if not raining at this time then return
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
if math.random() > PROCHA then
|
if math.random() > PROCHA then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local ppos = player:getpos()
|
local ppos = player:getpos()
|
||||||
if minetest.env:get_node_light(ppos, 0.5) ~= 15 then
|
if minetest.get_node_light(ppos, 0.5) ~= 15 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local perlins = minetest.env:get_perlin(SEEDS, OCTAS, PERSS, SCALS)
|
local snow = false
|
||||||
local noises = perlins:get2d({x = ppos.x, y = ppos.z})
|
local rain = false
|
||||||
if noises > SNOWT then -- if snow biome
|
local noiset
|
||||||
if math.random() < noises - SNOWT then
|
local noiseh
|
||||||
minetest.add_particle(
|
if SNOWV6 or THOVER then
|
||||||
{x = ppos.x - 64 + math.random(0, 128), y= ppos.y + 16, z= ppos.z - 48 + math.random(0, 128)}, -- posi
|
local perlint = minetest.get_perlin(SEEDT, OCTAT, PERST, SCALT)
|
||||||
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
noiset = perlint:get2d({x = ppos.x + 150, y = ppos.z + 50})
|
||||||
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
end
|
||||||
32,
|
if RAIN or THOVER then
|
||||||
2.8,
|
local perlinh = minetest.get_perlin(SEEDH, OCTAH, PERSH, SCALH)
|
||||||
false,
|
noiseh = perlinh:get2d({x = ppos.x, y = ppos.z})
|
||||||
"snowdrift_snowflake1.png",
|
end
|
||||||
player:get_player_name()
|
if THOVER then
|
||||||
)
|
if noiset < TET and noiseh > HUT then
|
||||||
minetest.add_particle(
|
snow = true
|
||||||
{x = ppos.x - 64 + math.random(0, 128), y= ppos.y + 16, z= ppos.z - 48 + math.random(0, 128)}, -- posi
|
elseif noiseh > HUT then
|
||||||
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
rain = true
|
||||||
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
|
||||||
32,
|
|
||||||
2.8,
|
|
||||||
false,
|
|
||||||
"snowdrift_snowflake2.png",
|
|
||||||
player:get_player_name()
|
|
||||||
)
|
|
||||||
minetest.add_particle(
|
|
||||||
{x = ppos.x - 64 + math.random(0, 128), y= ppos.y + 16, z= ppos.z - 48 + math.random(0, 128)}, -- posi
|
|
||||||
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
|
||||||
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
|
||||||
32,
|
|
||||||
2.8,
|
|
||||||
false,
|
|
||||||
"snowdrift_snowflake3.png",
|
|
||||||
player:get_player_name()
|
|
||||||
)
|
|
||||||
minetest.add_particle(
|
|
||||||
{x = ppos.x - 64 + math.random(0, 128), y= ppos.y + 16, z= ppos.z - 48 + math.random(0, 128)}, -- posi
|
|
||||||
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
|
||||||
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
|
||||||
32,
|
|
||||||
2.8,
|
|
||||||
false,
|
|
||||||
"snowdrift_snowflake4.png",
|
|
||||||
player:get_player_name()
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
else -- check rain noise
|
elseif SNOWV6 then
|
||||||
local perlinr = minetest.get_perlin(SEEDR, OCTAR, PERSR, SCALR)
|
if -noiset < TET then -- negative sign because snow mod noise is 'coldness'
|
||||||
local noiser = perlinr:get2d({x = ppos.x, y = ppos.z})
|
snow = true
|
||||||
if math.random() < noiser - RAINT then
|
elseif RAIN then
|
||||||
for drop = 1, 4 do
|
if noiseh > HUT then
|
||||||
minetest.add_particle(
|
rain = true
|
||||||
{x = ppos.x - 16 + math.random(0, 32), y= ppos.y + 16, z= ppos.z - 16 + math.random(0, 32)}, -- posi
|
|
||||||
{x = 0, y = -8, z = -1}, -- velo
|
|
||||||
{x = 0, y = 0, z = 0}, -- acce
|
|
||||||
4,
|
|
||||||
2.8,
|
|
||||||
false,
|
|
||||||
"snowdrift_raindrop.png",
|
|
||||||
player:get_player_name()
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif RAIN then
|
||||||
|
if noiseh > HUT then
|
||||||
|
rain = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if snow then
|
||||||
|
minetest.add_particle(
|
||||||
|
{x = ppos.x - 64 + math.random(0, 128), y = ppos.y + 16, z = ppos.z - 48 + math.random(0, 128)}, -- posi
|
||||||
|
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
||||||
|
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
||||||
|
32,
|
||||||
|
2.8,
|
||||||
|
false,
|
||||||
|
"snowdrift_snowflake1.png",
|
||||||
|
player:get_player_name()
|
||||||
|
)
|
||||||
|
minetest.add_particle(
|
||||||
|
{x = ppos.x - 64 + math.random(0, 128), y = ppos.y + 16, z = ppos.z - 48 + math.random(0, 128)}, -- posi
|
||||||
|
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
||||||
|
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
||||||
|
32,
|
||||||
|
2.8,
|
||||||
|
false,
|
||||||
|
"snowdrift_snowflake2.png",
|
||||||
|
player:get_player_name()
|
||||||
|
)
|
||||||
|
minetest.add_particle(
|
||||||
|
{x = ppos.x - 64 + math.random(0, 128), y = ppos.y + 16, z = ppos.z - 48 + math.random(0, 128)}, -- posi
|
||||||
|
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
||||||
|
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
||||||
|
32,
|
||||||
|
2.8,
|
||||||
|
false,
|
||||||
|
"snowdrift_snowflake3.png",
|
||||||
|
player:get_player_name()
|
||||||
|
)
|
||||||
|
minetest.add_particle(
|
||||||
|
{x = ppos.x - 64 + math.random(0, 128), y = ppos.y + 16, z = ppos.z - 48 + math.random(0, 128)}, -- posi
|
||||||
|
{x = math.random() / 5 - 0.1, y = math.random() / 5 - 1.1, z = math.random() / 5 - 1.1}, -- velo
|
||||||
|
{x = math.random() / 50 - 0.01, y = math.random() / 50 - 0.01, z = math.random() / 50 - 0.01}, -- acce
|
||||||
|
32,
|
||||||
|
2.8,
|
||||||
|
false,
|
||||||
|
"snowdrift_snowflake4.png",
|
||||||
|
player:get_player_name()
|
||||||
|
)
|
||||||
|
end
|
||||||
|
if rain then
|
||||||
|
for drop = 1, DROPS do
|
||||||
|
minetest.add_particle(
|
||||||
|
{
|
||||||
|
x = ppos.x - 16 + math.random(0, 32),
|
||||||
|
y = ppos.y + 16,
|
||||||
|
z = ppos.z - 16 + math.random(0, 32)
|
||||||
|
}, -- posi
|
||||||
|
{x = 0, y = -8, z = -1}, -- velo
|
||||||
|
{x = 0, y = 0, z = 0}, -- acce
|
||||||
|
4,
|
||||||
|
2.8,
|
||||||
|
false,
|
||||||
|
"snowdrift_raindrop.png",
|
||||||
|
player:get_player_name()
|
||||||
|
)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
Loading…
Reference in New Issue