2019-09-01 23:18:53 -04:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
|
|
|
local math, minetest, nodecore, pairs, vector
|
|
|
|
= math, minetest, nodecore, pairs, vector
|
2019-09-02 11:34:14 -04:00
|
|
|
local math_exp, math_random
|
|
|
|
= math.exp, math.random
|
2019-09-01 23:18:53 -04:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
2019-09-07 09:08:57 -04:00
|
|
|
nodecore.amcoremod()
|
|
|
|
|
2020-01-11 08:31:33 -05:00
|
|
|
local function dsqr(a, b)
|
|
|
|
local v = vector.subtract(a, b)
|
|
|
|
return vector.dot(v, v)
|
|
|
|
end
|
|
|
|
|
|
|
|
local function check(pos, done, srcs)
|
2019-09-01 23:18:53 -04:00
|
|
|
local sp = {
|
|
|
|
x = pos.x + math_random() * 64 - 32,
|
|
|
|
y = pos.y + math_random() * 64 - 32,
|
|
|
|
z = pos.z + math_random() * 64 - 32,
|
|
|
|
}
|
2019-09-02 11:24:03 -04:00
|
|
|
|
2020-01-11 08:31:33 -05:00
|
|
|
if dsqr(sp, pos) > (32 * 32) then return end
|
2019-09-01 23:18:53 -04:00
|
|
|
for p in pairs(done) do
|
2020-01-11 08:31:33 -05:00
|
|
|
if dsqr(sp, p) < (32 * 32) then return end
|
|
|
|
end
|
|
|
|
for p in pairs(srcs) do
|
|
|
|
if dsqr(sp, p) < (4 * 4) then return end
|
2019-09-01 23:18:53 -04:00
|
|
|
end
|
2019-09-02 11:24:03 -04:00
|
|
|
if minetest.get_node(sp).name ~= "air" then return end
|
|
|
|
|
2020-02-22 16:55:42 -05:00
|
|
|
if nodecore.is_full_sun(sp) then
|
2019-09-02 11:24:03 -04:00
|
|
|
if sp.y <= 0 then return end
|
2020-04-05 21:22:51 -04:00
|
|
|
nodecore.sound_play("nc_envsound_air", {
|
2019-09-02 11:24:03 -04:00
|
|
|
pos = sp,
|
2019-09-02 11:34:14 -04:00
|
|
|
gain = nodecore.windiness(sp.y) / 100
|
2019-09-02 11:24:03 -04:00
|
|
|
})
|
2020-02-22 16:55:42 -05:00
|
|
|
elseif nodecore.get_node_light(sp) < 4 then
|
2020-04-05 21:22:51 -04:00
|
|
|
nodecore.sound_play("nc_envsound_drip", {
|
2019-09-02 11:24:03 -04:00
|
|
|
pos = sp,
|
|
|
|
pitchvary = 0.4,
|
|
|
|
gain = math_exp(math_random()) / 5
|
|
|
|
})
|
|
|
|
end
|
|
|
|
|
2019-09-01 23:18:53 -04:00
|
|
|
done[pos] = true
|
|
|
|
end
|
|
|
|
|
|
|
|
local oldpos = {}
|
|
|
|
local function run()
|
|
|
|
minetest.after(math_random(), run)
|
2020-01-11 08:31:33 -05:00
|
|
|
local srcs = {}
|
2019-09-01 23:18:53 -04:00
|
|
|
for _, pl in pairs(minetest.get_connected_players()) do
|
2020-01-11 08:31:33 -05:00
|
|
|
if nodecore.player_visible(pl) then
|
|
|
|
local pname = pl:get_player_name()
|
|
|
|
local pos = pl:get_pos()
|
|
|
|
local op = oldpos[pname] or pos
|
|
|
|
oldpos[pname] = pos
|
|
|
|
pos = vector.add(pos, vector.multiply(vector.subtract(pos, op), 3))
|
|
|
|
srcs[#srcs + 1] = pos
|
|
|
|
end
|
2019-09-01 23:18:53 -04:00
|
|
|
end
|
2020-01-11 08:31:33 -05:00
|
|
|
local done = {}
|
|
|
|
for _, pos in pairs(srcs) do
|
|
|
|
check(pos, done, srcs)
|
|
|
|
end
|
|
|
|
|
2019-09-01 23:18:53 -04:00
|
|
|
end
|
|
|
|
run()
|