Disable under a y limit set by parameter, usually set to a world's water level

master
paramat 2017-04-15 23:24:14 +01:00
parent 78b6e10d73
commit fcb0537b32
1 changed files with 121 additions and 114 deletions

View File

@ -1,5 +1,7 @@
-- 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 PRECOFF = -0.4 -- Precipitation offset, higher = rains more often
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
local player_name = player:get_player_name()
local ppos = player:getpos()
local pposx = math.floor(ppos.x)
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 ppos = {x = pposx, y = pposy, z = pposz}
@ -207,6 +209,11 @@ minetest.register_globalstep(function(dtime)
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)