From 9c9e525cd7a24dd3f29e4ee073b7c0f7dbfa690e Mon Sep 17 00:00:00 2001 From: Vanessa Ezekowitz Date: Sun, 10 May 2015 22:08:34 -0400 Subject: [PATCH] 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 --- homedecor/bathroom_sanitation.lua | 42 ++++++++++++++++++++++++-- homedecor/handlers/water_particles.lua | 10 +++--- homedecor/kitchen_furniture.lua | 13 ++++++++ 3 files changed, 58 insertions(+), 7 deletions(-) diff --git a/homedecor/bathroom_sanitation.lua b/homedecor/bathroom_sanitation.lua index 702298af..79bd80c0 100644 --- a/homedecor/bathroom_sanitation.lua +++ b/homedecor/bathroom_sanitation.lua @@ -95,13 +95,44 @@ homedecor.register("sink", { }, inventory_image="homedecor_bathroom_sink_inv.png", selection_box = sink_cbox, - collision_box = sink_cbox, groups = {cracky=3}, 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 +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", { description = S("Bathroom taps/faucet"), mesh = "homedecor_bathroom_faucet.obj", @@ -120,6 +151,8 @@ homedecor.register("taps", { walkable = false, groups = {cracky=3}, sounds = default.node_sound_stone_defaults(), + on_rightclick = taps_on_rightclick, + on_destruct = homedecor.stop_particle_spawner }) homedecor.register("taps_brass", { @@ -140,6 +173,8 @@ homedecor.register("taps_brass", { walkable = false, groups = {cracky=3}, sounds = default.node_sound_stone_defaults(), + on_rightclick = taps_on_rightclick, + on_destruct = homedecor.stop_particle_spawner }) --Shower Tray @@ -167,8 +202,8 @@ homedecor.register("shower_tray", { groups = {cracky=2}, sounds = default.node_sound_stone_defaults(), on_destruct = function(pos) - headpos = {x=pos.x, y=pos.y+2, z=pos.z} - homedecor.stop_particle_spawner(headpos) + homedecor.stop_particle_spawner({x=pos.x, y=pos.y+2, z=pos.z}) -- the showerhead + homedecor.stop_particle_spawner({x=pos.x, y=pos.y+1, z=pos.z}) -- the taps, if any end }) @@ -200,6 +235,7 @@ homedecor.register("shower_head", { outlet_y = -0.42, outlet_z = 0.1, velocity_x = { min = -0.15, max = 0.15 }, + velocity_y = -2, velocity_z = { min = -0.3, max = 0.1 }, spread = 0.12 } diff --git a/homedecor/handlers/water_particles.lua b/homedecor/handlers/water_particles.lua index 7bbe9688..42d363df 100644 --- a/homedecor/handlers/water_particles.lua +++ b/homedecor/handlers/water_particles.lua @@ -7,8 +7,9 @@ -- outletx/y/z are the exact coords of the starting point -- for the spawner, relative to the center of the node -- --- velocityx/y are the speed of the particles, --- relative to a node placed while looking north (facedir 0) +-- velocityx/y/z are the speed of the particles, +-- (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, -- 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 outletz = particledef.outlet_z local velocityx = particledef.velocity_x + local velocityy = particledef.velocity_y local velocityz = particledef.velocity_z local spread = particledef.spread @@ -71,8 +73,8 @@ function homedecor.start_particle_spawner(pos, node, particledef, soundname) collisiondetection = true, 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}, - minvel = {x = minvelx, y=-2, z = minvelz}, - maxvel = {x = maxvelx, y=-2, z = maxvelz}, + minvel = {x = minvelx, y = velocityy, z = minvelz}, + maxvel = {x = maxvelx, y = velocityy, z = maxvelz}, minacc = {x=0, y=0, z=0}, maxacc = {x=0, y=-0.05, z=0}, minexptime = 2, diff --git a/homedecor/kitchen_furniture.lua b/homedecor/kitchen_furniture.lua index cd39c853..225cff6d 100644 --- a/homedecor/kitchen_furniture.lua +++ b/homedecor/kitchen_furniture.lua @@ -69,6 +69,19 @@ homedecor.register("kitchen_cabinet_with_sink", { inventory = { 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 = {