Add player position prediction. Add particle radius parameters
parent
0a0787a8f1
commit
67f04e72fa
15
init.lua
15
init.lua
|
@ -12,6 +12,8 @@ local RAINGAIN = 0.2 -- Rain sound volume
|
||||||
local COLLIDE = false -- Whether particles collide with nodes
|
local COLLIDE = false -- Whether particles collide with nodes
|
||||||
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
|
||||||
|
local FRADIUS = 48 -- Radius in which flakes are created
|
||||||
|
local DRADIUS = 24 -- Radius in which drops are created
|
||||||
|
|
||||||
local np_prec = {
|
local np_prec = {
|
||||||
offset = 0,
|
offset = 0,
|
||||||
|
@ -78,7 +80,10 @@ minetest.register_globalstep(function(dtime)
|
||||||
|
|
||||||
for _, player in ipairs(minetest.get_connected_players()) do
|
for _, player in ipairs(minetest.get_connected_players()) do
|
||||||
local player_name = player:get_player_name()
|
local player_name = player:get_player_name()
|
||||||
local ppos = player:getpos()
|
-- Predict player position as slightly behind the CYCLE interval.
|
||||||
|
-- Assume scheduling gets behind slighly (the 1.5), this also tested well.
|
||||||
|
local ppos = vector.add(player:getpos(),
|
||||||
|
vector.multiply(player:get_player_velocity(), GSCYCLE * 1.5))
|
||||||
local pposy = math.floor(ppos.y) + 2 -- Precipitation when swimming
|
local pposy = math.floor(ppos.y) + 2 -- Precipitation when swimming
|
||||||
if pposy >= YLIMIT - 2 then
|
if pposy >= YLIMIT - 2 then
|
||||||
local pposx = math.floor(ppos.x)
|
local pposx = math.floor(ppos.x)
|
||||||
|
@ -156,9 +161,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
for flake = 1, FLAKES do
|
for flake = 1, FLAKES do
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = {
|
pos = {
|
||||||
x = pposx - 24 + math.random(0, 48),
|
x = pposx - FRADIUS + math.random(0, FRADIUS * 2),
|
||||||
y = pposy + 12,
|
y = pposy + 12,
|
||||||
z = pposz - 24 + math.random(0, 48)
|
z = pposz - FRADIUS + math.random(0, FRADIUS * 2)
|
||||||
},
|
},
|
||||||
velocity = {
|
velocity = {
|
||||||
x = (-20 + math.random(0, 40)) / 100,
|
x = (-20 + math.random(0, 40)) / 100,
|
||||||
|
@ -183,9 +188,9 @@ minetest.register_globalstep(function(dtime)
|
||||||
local extime = math.min((spawny - YLIMIT) / 10, 1.8)
|
local extime = math.min((spawny - YLIMIT) / 10, 1.8)
|
||||||
minetest.add_particle({
|
minetest.add_particle({
|
||||||
pos = {
|
pos = {
|
||||||
x = pposx - 12 + math.random(0, 24),
|
x = pposx - DRADIUS + math.random(0, DRADIUS * 2),
|
||||||
y = spawny,
|
y = spawny,
|
||||||
z = pposz - 12 + math.random(0, 24)
|
z = pposz - DRADIUS + math.random(0, DRADIUS * 2)
|
||||||
},
|
},
|
||||||
velocity = {
|
velocity = {
|
||||||
x = 0.0,
|
x = 0.0,
|
||||||
|
|
Loading…
Reference in New Issue