Disable under a y limit set by parameter, usually set to a world's water level
This commit is contained in:
parent
78b6e10d73
commit
fcb0537b32
11
init.lua
11
init.lua
@ -1,5 +1,7 @@
|
|||||||
-- Parameters
|
-- Parameters
|
||||||
|
|
||||||
|
local YLIMIT = 1 -- Set to world's water level or level of lowest open area,
|
||||||
|
-- calculations are disabled below this y.
|
||||||
local PRECSPR = 6 -- Time scale for precipitation variation in minutes
|
local PRECSPR = 6 -- Time scale for precipitation variation in minutes
|
||||||
local PRECOFF = -0.4 -- Precipitation offset, higher = rains more often
|
local PRECOFF = -0.4 -- Precipitation offset, higher = rains more often
|
||||||
local GSCYCLE = 0.5 -- Globalstep cycle (seconds)
|
local GSCYCLE = 0.5 -- Globalstep cycle (seconds)
|
||||||
@ -75,10 +77,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()
|
local ppos = player:getpos()
|
||||||
local pposx = math.floor(ppos.x)
|
|
||||||
local pposy = math.floor(ppos.y) + 2 -- Precipitation when swimming
|
local pposy = math.floor(ppos.y) + 2 -- Precipitation when swimming
|
||||||
|
if pposy >= YLIMIT then
|
||||||
|
local pposx = math.floor(ppos.x)
|
||||||
local pposz = math.floor(ppos.z)
|
local pposz = math.floor(ppos.z)
|
||||||
local ppos = {x = pposx, y = pposy, z = pposz}
|
local ppos = {x = pposx, y = pposy, z = pposz}
|
||||||
|
|
||||||
@ -207,6 +209,11 @@ minetest.register_globalstep(function(dtime)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
elseif handles[player_name] then
|
||||||
|
-- Stop sound when player goes under y limit
|
||||||
|
minetest.sound_stop(handles[player_name])
|
||||||
|
handles[player_name] = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user