--make it float
if minetest.get_item_group(node.name, "water") ~= 0 and y == 0 then
if object:get_luaentity().in_water == false then
--do sounds and particles for water bounces
if velocity.y < 0 and velocity.y > -3 then
minetest.sound_play("soft_splash", {
pos = {object:getpos()},
max_hear_distance = 20,
gain = 0.01,
})
minetest.add_particlespawner({
amount = 10,
time = 1,
minpos = {x=realpos.x-1, y=realpos.y, z=realpos.z-1},
maxpos = {x=realpos.x+1, y=realpos.y, z=realpos.z+1},
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=1, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = false,
vertical = false,
texture = "bubble.png",
})
elseif velocity.y <= -3 and velocity.y > -10 then
minetest.sound_play("medium_splash", {
pos = {object:getpos()},
max_hear_distance = 20,
gain = 0.05,
})
minetest.add_particlespawner({
amount = 15,
time = 1,
minpos = {x=realpos.x-1, y=realpos.y, z=realpos.z-1},
maxpos = {x=realpos.x+1, y=realpos.y, z=realpos.z+1},
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=2, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = false,
vertical = false,
texture = "bubble.png",
})
elseif velocity.y <= -10 then
minetest.sound_play("big_splash", {
pos = {object:getpos()},
max_hear_distance = 20,
gain = 0.07,
})
minetest.add_particlespawner({
amount = 20,
time = 0.5,
minpos = {x=realpos.x-1, y=realpos.y, z=realpos.z-1},
maxpos = {x=realpos.x+1, y=realpos.y, z=realpos.z+1},
minvel = {x=0, y=0, z=0},
maxvel = {x=0, y=0, z=0},
minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=3, z=0},
minexptime = 1,
maxexptime = 1,
minsize = 1,
maxsize = 1,
collisiondetection = false,
vertical = false,
texture = "bubble.png",
})
end
end
object:get_luaentity().in_water = true
object:setacceleration({x=x,y=4,z=z})
--slow down boats that fall into water smoothly
if velocity.y < 0 then
object:setacceleration({x=x,y=10,z=z})
end
end
texmex wrote:Also looking for this. Perhaps a simpler version that checks for water above a new type of buoyant block, and rises it until water is not above it anymore. I can't program but I've seen the mechanic in other mods such as vines and also the builtin falling.lua feature.
Floating wood node?
Users browsing this forum: No registered users and 8 guests