make bathroom taps use the new particles code

also make shower tray turn off taps above it, if any
minor tweak to particles function to add Y velocity
added more detailed collision boxes to the sinks to accommodate particles
This commit is contained in:
Vanessa Ezekowitz 2015-05-10 22:08:34 -04:00
parent 12f5ac9d02
commit 9c9e525cd7
3 changed files with 58 additions and 7 deletions

View File

@ -95,13 +95,44 @@ homedecor.register("sink", {
}, },
inventory_image="homedecor_bathroom_sink_inv.png", inventory_image="homedecor_bathroom_sink_inv.png",
selection_box = sink_cbox, selection_box = sink_cbox,
collision_box = sink_cbox,
groups = {cracky=3}, groups = {cracky=3},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
node_box = {
type = "fixed",
fixed = {
{ -5/16, 5/16, 1/16, -4/16, 8/16, 8/16 },
{ 5/16, 5/16, 1/16, 4/16, 8/16, 8/16 },
{ -5/16, 5/16, 1/16, 5/16, 8/16, 2/16 },
{ -5/16, 5/16, 6/16, 5/16, 8/16, 8/16 },
{ -4/16, -8/16, 1/16, 4/16, 5/16, 6/16 }
}
},
on_destruct = function(pos)
homedecor.stop_particle_spawner({x=pos.x, y=pos.y+1, z=pos.z})
end
}) })
--Taps --Taps
local function taps_on_rightclick(pos, node, clicker)
local below = minetest.get_node_or_nil({x=pos.x, y=pos.y-1, z=pos.z})
if below and
string.find(below.name, "homedecor:shower_tray") or
string.find(below.name, "homedecor:sink") or
string.find(below.name, "homedecor:kitchen_cabinet_with_sink") then
local particledef = {
outlet_x = 0,
outlet_y = -0.44,
outlet_z = 0.28,
velocity_x = { min = -0.1, max = 0.1 },
velocity_y = -0.3,
velocity_z = { min = -0.1, max = 0 },
spread = 0
}
homedecor.start_particle_spawner(pos, node, particledef, "homedecor_shower")
end
end
homedecor.register("taps", { homedecor.register("taps", {
description = S("Bathroom taps/faucet"), description = S("Bathroom taps/faucet"),
mesh = "homedecor_bathroom_faucet.obj", mesh = "homedecor_bathroom_faucet.obj",
@ -120,6 +151,8 @@ homedecor.register("taps", {
walkable = false, walkable = false,
groups = {cracky=3}, groups = {cracky=3},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_rightclick = taps_on_rightclick,
on_destruct = homedecor.stop_particle_spawner
}) })
homedecor.register("taps_brass", { homedecor.register("taps_brass", {
@ -140,6 +173,8 @@ homedecor.register("taps_brass", {
walkable = false, walkable = false,
groups = {cracky=3}, groups = {cracky=3},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_rightclick = taps_on_rightclick,
on_destruct = homedecor.stop_particle_spawner
}) })
--Shower Tray --Shower Tray
@ -167,8 +202,8 @@ homedecor.register("shower_tray", {
groups = {cracky=2}, groups = {cracky=2},
sounds = default.node_sound_stone_defaults(), sounds = default.node_sound_stone_defaults(),
on_destruct = function(pos) on_destruct = function(pos)
headpos = {x=pos.x, y=pos.y+2, z=pos.z} homedecor.stop_particle_spawner({x=pos.x, y=pos.y+2, z=pos.z}) -- the showerhead
homedecor.stop_particle_spawner(headpos) homedecor.stop_particle_spawner({x=pos.x, y=pos.y+1, z=pos.z}) -- the taps, if any
end end
}) })
@ -200,6 +235,7 @@ homedecor.register("shower_head", {
outlet_y = -0.42, outlet_y = -0.42,
outlet_z = 0.1, outlet_z = 0.1,
velocity_x = { min = -0.15, max = 0.15 }, velocity_x = { min = -0.15, max = 0.15 },
velocity_y = -2,
velocity_z = { min = -0.3, max = 0.1 }, velocity_z = { min = -0.3, max = 0.1 },
spread = 0.12 spread = 0.12
} }

View File

@ -7,8 +7,9 @@
-- outletx/y/z are the exact coords of the starting point -- outletx/y/z are the exact coords of the starting point
-- for the spawner, relative to the center of the node -- for the spawner, relative to the center of the node
-- --
-- velocityx/y are the speed of the particles, -- velocityx/y/z are the speed of the particles,
-- relative to a node placed while looking north (facedir 0) -- (x and z are relative to a node placed while looking north/facedir 0)
-- negative Y values flow downward.
-- --
-- spread is the radius from the starting point, -- spread is the radius from the starting point,
-- along X and Z only, to randomly spawn particles. -- along X and Z only, to randomly spawn particles.
@ -42,6 +43,7 @@ function homedecor.start_particle_spawner(pos, node, particledef, soundname)
local outlety = particledef.outlet_y local outlety = particledef.outlet_y
local outletz = particledef.outlet_z local outletz = particledef.outlet_z
local velocityx = particledef.velocity_x local velocityx = particledef.velocity_x
local velocityy = particledef.velocity_y
local velocityz = particledef.velocity_z local velocityz = particledef.velocity_z
local spread = particledef.spread local spread = particledef.spread
@ -71,8 +73,8 @@ function homedecor.start_particle_spawner(pos, node, particledef, soundname)
collisiondetection = true, collisiondetection = true,
minpos = {x=pos.x - minx, y=pos.y + outlety, z=pos.z - minz}, minpos = {x=pos.x - minx, y=pos.y + outlety, z=pos.z - minz},
maxpos = {x=pos.x - maxx, y=pos.y + outlety, z=pos.z - maxz}, maxpos = {x=pos.x - maxx, y=pos.y + outlety, z=pos.z - maxz},
minvel = {x = minvelx, y=-2, z = minvelz}, minvel = {x = minvelx, y = velocityy, z = minvelz},
maxvel = {x = maxvelx, y=-2, z = maxvelz}, maxvel = {x = maxvelx, y = velocityy, z = maxvelz},
minacc = {x=0, y=0, z=0}, minacc = {x=0, y=0, z=0},
maxacc = {x=0, y=-0.05, z=0}, maxacc = {x=0, y=-0.05, z=0},
minexptime = 2, minexptime = 2,

View File

@ -69,6 +69,19 @@ homedecor.register("kitchen_cabinet_with_sink", {
inventory = { inventory = {
size=16, size=16,
}, },
node_box = {
type = "fixed",
fixed = {
{ -8/16, -8/16, -8/16, 8/16, 6/16, 8/16 },
{ -8/16, 6/16, -8/16, -6/16, 8/16, 8/16 },
{ 6/16, 6/16, -8/16, 8/16, 8/16, 8/16 },
{ -8/16, 6/16, -8/16, 8/16, 8/16, -6/16 },
{ -8/16, 6/16, 6/16, 8/16, 8/16, 8/16 },
}
},
on_destruct = function(pos)
homedecor.stop_particle_spawner({x=pos.x, y=pos.y+1, z=pos.z})
end
}) })
local cp_cbox = { local cp_cbox = {