Make puddle particles respect puddle height

This commit is contained in:
Wuzzy 2023-12-07 15:53:37 +01:00
parent c6dfe0d845
commit 02f7897bfc

View File

@ -7,7 +7,7 @@ local PUDDLE_PARTICLES = 12
local SNOW_PARTICLES = 4
local MUD_PARTICLES = 3
local splash = function(player, particlenode, amount)
local splash = function(player, offset, particlenode, amount)
minetest.add_particlespawner({
amount = amount,
time = 0.05,
@ -15,11 +15,11 @@ local splash = function(player, particlenode, amount)
min = 1,
max = 1.5,
},
pos = vector.zero(),
pos = offset,
attached = player,
vel = {
min = vector.new(-2, 1, -2),
max = vector.new(2, 3, 2),
min = vector.new(-2, 2, -2),
max = vector.new(2, 4, 2),
},
bounce = 0.5,
drag = vector.new(5, 0, 5),
@ -35,16 +35,19 @@ local function step_effect(player)
local nodei = minetest.get_node(pos)
local below = vector.add(pos, vector.new(0, -1, 0))
local nodeb = minetest.get_node(below)
local offset = vector.zero()
if minetest.get_item_group(nodei.name, "puddle") == 1 then
splash(player, nodei, PUDDLE_PARTICLES)
local height = nodei.param2 / 64
offset.y = height
splash(player, offset, nodei, PUDDLE_PARTICLES)
elseif minetest.get_item_group(nodeb.name, "snow") == 1 then
splash(player, nodeb, SNOW_PARTICLES)
splash(player, offset, nodeb, SNOW_PARTICLES)
elseif minetest.get_item_group(nodei.name, "snow") == 1 then
splash(player, nodei, SNOW_PARTICLES)
splash(player, offset, nodei, SNOW_PARTICLES)
elseif minetest.get_item_group(nodeb.name, "mud") == 1 then
splash(player, nodeb, MUD_PARTICLES)
splash(player, offset, nodeb, MUD_PARTICLES)
elseif minetest.get_item_group(nodei.name, "mud") == 1 then
splash(player, nodei, MUD_PARTICLES)
splash(player, offset, nodei, MUD_PARTICLES)
end
end