From 33386b19caef3e2985d6e2e1b7864b138005c98c Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Mon, 8 Jan 2018 20:11:33 +0100 Subject: [PATCH] Drop lever when attached node is destroyed --- .../REDSTONE/mesecons_walllever/init.lua | 30 ++- .../models/jeija_wall_lever_off.obj | 172 +++++++++--------- .../models/jeija_wall_lever_on.obj | 170 ++++++++--------- 3 files changed, 182 insertions(+), 190 deletions(-) diff --git a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua index 9ac9e98817..72bfee16b4 100644 --- a/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua +++ b/mods/ITEMS/REDSTONE/mesecons_walllever/init.lua @@ -29,9 +29,9 @@ minetest.register_node("mesecons_walllever:wall_lever_off", { walkable = false, selection_box = { type = "fixed", - fixed = { -3/16, -8/16, -4/16, 3/16, -2/16, 4/16 }, + fixed = { -3/16, -4/16, 2/16, 3/16, 4/16, 8/16 }, }, - groups = {handy=1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {handy=1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, attached_node_facedir=1}, is_ground_content = false, description="Lever", _doc_items_longdesc = "A lever is a redstone component which can be flipped on and off. It supplies redstone power to the blocks behind while it is in the “on” state.", @@ -77,30 +77,22 @@ minetest.register_node("mesecons_walllever:wall_lever_off", { end local above = pointed_thing.above - local dir = vector.subtract(above, under) - local wdir + local dir = vector.subtract(under, above) local tau = math.pi*2 - if dir.z == 1 then - wdir = 6 - elseif dir.z == -1 then - wdir = 8 - elseif dir.x == 1 then - wdir = 15 - elseif dir.x == -1 then - wdir = 17 - elseif dir.y ~= 0 then + local wdir = minetest.dir_to_facedir(dir, true) + if dir.y ~= 0 then local yaw = placer:get_look_horizontal() if (yaw > tau/8 and yaw < (tau/8)*3) or (yaw < (tau/8)*7 and yaw > (tau/8)*5) then if dir.y == -1 then - wdir = 23 + wdir = 13 else - wdir = 1 + wdir = 15 end else if dir.y == -1 then - wdir = 22 + wdir = 10 else - wdir = 2 + wdir = 8 end end end @@ -138,9 +130,9 @@ minetest.register_node("mesecons_walllever:wall_lever_on", { walkable = false, selection_box = { type = "fixed", - fixed = { -3/16, -8/16, -4/16, 3/16, -2/16, 4/16 }, + fixed = { -3/16, -4/16, 2/16, 3/16, 4/16, 8/16 }, }, - groups = {handy=1, not_in_creative_inventory = 1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1}, + groups = {handy=1, not_in_creative_inventory = 1, dig_by_water=1, destroy_by_lava_flow=1, dig_by_piston=1, attached_node_facedir=1}, is_ground_content = false, drop = '"mesecons_walllever:wall_lever_off" 1', description="Lever", diff --git a/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_off.obj b/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_off.obj index 22df3acfd9..158387ea38 100644 --- a/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_off.obj +++ b/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_off.obj @@ -1,90 +1,90 @@ -# Blender v2.78 (sub 0) OBJ File: '' +# Blender v2.79 (sub 0) OBJ File: '' # www.blender.org -mtllib jeija_wall_lever_on.mtl -o nodebox1.002 -v -0.070437 -0.459607 0.138449 -v -0.070383 -0.407163 0.058550 -v -0.070618 -0.117856 0.289534 -v -0.070672 -0.170301 0.369433 -v 0.054549 -0.459593 0.139679 -v 0.054604 -0.407150 0.059783 -v 0.054369 -0.117843 0.290768 -v 0.054313 -0.170287 0.370665 -vt 0.0625 0.5625 -vt 0.1250 0.5625 -vt 0.1250 0.8750 -vt 0.0625 0.8750 -vt 0.1875 0.5625 -vt 0.2500 0.5625 -vt 0.2500 0.8750 -vt 0.1875 0.8750 -vt 0.1250 0.5625 -vt 0.1250 0.8750 -vt 0.0625 0.8750 -vt 0.0625 0.5625 -vt 0.2500 0.5625 -vt 0.2500 0.8750 -vt 0.1875 0.8750 -vt 0.1875 0.5625 -vt 0.6250 0.8750 -vt 0.6250 0.9375 -vt 0.5625 0.9375 -vt 0.5625 0.8750 -vt 0.0000 0.0000 -vt 0.0000 0.0000 -vt 0.0000 0.0000 -vt 0.0000 0.0000 -vn 1.0000 0.0002 0.0008 -vn 0.0076 0.6239 -0.7814 -vn 0.0076 0.6239 -0.7815 -vn 0.0055 -0.8360 -0.5487 -usemtl none.000 +mtllib jeija_wall_lever_off.mtl +o nodebox1.001 +v -0.170183 0.248882 0.492124 +v -0.161792 -0.249536 0.496140 +v -0.161781 -0.250523 0.373114 +v -0.170172 0.247894 0.369098 +v 0.161753 0.245254 0.492135 +v 0.170145 -0.253163 0.496151 +v 0.170155 -0.254151 0.373125 +v 0.161764 0.244266 0.369109 +vt 0.500000 0.203100 +vt 0.000000 0.203100 +vt 0.000000 0.000000 +vt 0.500000 0.000000 +vt 0.500000 0.203100 +vt 0.000000 0.203100 +vt 0.000000 0.000000 +vt 0.500000 0.000000 +vt 0.000000 0.203100 +vt 0.000100 0.000100 +vt 0.500000 0.000000 +vt 0.500000 0.203100 +vt 0.000000 0.203100 +vt 0.000000 -0.000000 +vt 0.000000 0.500000 +vt 0.000000 0.000000 +vt 0.500000 -0.000000 +vt 0.500000 0.500000 +vt -0.000000 0.500000 +vt 0.500000 -0.000000 +vt 0.500000 0.500000 +vn 0.9999 0.0168 -0.0000 +vn 0.9999 0.0168 -0.0001 +vn -0.0109 -0.9999 0.0080 +vn 0.0001 0.0081 1.0000 +usemtl none.003 s 1 f 1/1/1 2/2/1 3/3/1 4/4/1 -f 5/5/1 6/6/1 7/7/1 8/8/1 -f 1/9/2 4/10/2 8/11/2 5/12/2 -f 2/13/3 3/14/3 7/15/3 6/16/3 -f 4/17/4 3/18/4 7/19/4 8/20/4 -usemtl none.000_NONE -f 1/21/4 2/22/4 6/23/4 5/24/4 -o nodebox1.003 -v -0.170183 -0.492185 0.248761 -v -0.161792 -0.496079 -0.249657 -v -0.161781 -0.373053 -0.250614 -v -0.170172 -0.369159 0.247804 -v 0.161753 -0.492195 0.245133 -v 0.170145 -0.496089 -0.253285 -v 0.170155 -0.373063 -0.254242 -v 0.161764 -0.369169 0.244176 -vt 0.5000 0.2031 -vt 0.0000 0.2031 -vt 0.0000 0.0000 -vt 0.5000 0.0000 -vt 0.5000 0.2031 -vt 0.0000 0.2031 -vt 0.0000 0.0000 -vt 0.5000 0.0000 -vt 0.0000 0.2031 -vt 0.0001 0.0001 -vt 0.5000 0.0000 -vt 0.5000 0.2031 -vt 0.0000 0.2031 -vt 0.0000 -0.0000 -vt 0.0000 0.5000 -vt 0.0000 0.0000 -vt 0.5000 -0.0000 -vt 0.5000 0.5000 -vt -0.0000 0.5000 -vt 0.5000 -0.0000 -vt 0.5000 0.5000 -vn 0.9999 0.0000 0.0168 -vn -0.0109 -0.0078 -0.9999 -vn 0.0001 -1.0000 0.0078 -usemtl none.001 +f 5/5/2 6/6/2 7/7/2 8/8/2 +f 1/9/3 4/10/3 8/8/3 5/5/3 +f 2/11/3 3/12/3 7/13/3 6/14/3 +f 1/15/4 2/16/4 6/17/4 5/18/4 +f 4/19/4 3/3/4 7/20/4 8/21/4 +o nodebox1.000 +v -0.070437 0.138562 0.459573 +v -0.070383 0.058650 0.407149 +v -0.070618 0.289563 0.117785 +v -0.070672 0.369475 0.170211 +v 0.054549 0.139792 0.459559 +v 0.054604 0.059883 0.407135 +v 0.054369 0.290797 0.117772 +v 0.054313 0.370707 0.170196 +vt 0.062500 0.562500 +vt 0.125000 0.562500 +vt 0.125000 0.875000 +vt 0.062500 0.875000 +vt 0.187500 0.562500 +vt 0.250000 0.562500 +vt 0.250000 0.875000 +vt 0.187500 0.875000 +vt 0.125000 0.562500 +vt 0.125000 0.875000 +vt 0.062500 0.875000 +vt 0.062500 0.562500 +vt 0.250000 0.562500 +vt 0.250000 0.875000 +vt 0.187500 0.875000 +vt 0.187500 0.562500 +vt 0.625000 0.875000 +vt 0.625000 0.937500 +vt 0.562500 0.937500 +vt 0.562500 0.875000 +vt 0.000000 0.000000 +vt 0.000000 0.000000 +vt 0.000000 0.000000 +vt 0.000000 0.000000 +vn 1.0000 0.0008 -0.0002 +vn 0.0076 -0.7816 -0.6237 +vn 0.0055 -0.5485 0.8361 +usemtl none.002 s 1 -f 9/25/5 10/26/5 11/27/5 12/28/5 -f 13/29/5 14/30/5 15/31/5 16/32/5 -f 9/33/6 12/34/6 16/32/6 13/29/6 -f 10/35/6 11/36/6 15/37/6 14/38/6 -f 9/39/7 10/40/7 14/41/7 13/42/7 -f 12/43/7 11/27/7 15/44/7 16/45/7 +f 9/22/5 10/23/5 11/24/5 12/25/5 +f 13/26/5 14/27/5 15/28/5 16/29/5 +f 9/30/6 12/31/6 16/32/6 13/33/6 +f 10/34/6 11/35/6 15/36/6 14/37/6 +f 12/38/7 11/39/7 15/40/7 16/41/7 +usemtl none.000_NONE.001 +f 9/42/7 10/43/7 14/44/7 13/45/7 diff --git a/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_on.obj b/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_on.obj index 5852fa96c3..e0874ecf82 100644 --- a/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_on.obj +++ b/mods/ITEMS/REDSTONE/mesecons_walllever/models/jeija_wall_lever_on.obj @@ -1,90 +1,90 @@ -# Blender v2.78 (sub 0) OBJ File: '' +# Blender v2.79 (sub 0) OBJ File: '' # www.blender.org -mtllib jeija_wall_lever_off.mtl -o nodebox1.007 -v -0.170183 -0.492185 0.248761 -v -0.161792 -0.496079 -0.249657 -v -0.161781 -0.373053 -0.250614 -v -0.170172 -0.369159 0.247804 -v 0.161753 -0.492195 0.245133 -v 0.170145 -0.496089 -0.253285 -v 0.170155 -0.373063 -0.254242 -v 0.161764 -0.369169 0.244176 -vt 0.5000 0.2031 -vt 0.0000 0.2031 -vt 0.0000 0.0000 -vt 0.5000 0.0000 -vt 0.5000 0.2031 -vt 0.0000 0.2031 -vt 0.0000 0.0000 -vt 0.5000 0.0000 -vt 0.0000 0.2031 -vt 0.0001 0.0001 -vt 0.5000 0.0000 -vt 0.5000 0.2031 -vt 0.0000 0.2031 -vt 0.0000 -0.0000 -vt 0.0000 0.5000 -vt 0.0000 0.0000 -vt 0.5000 -0.0000 -vt 0.5000 0.5000 -vt -0.0000 0.5000 -vt 0.5000 -0.0000 -vt 0.5000 0.5000 -vn 0.9999 0.0000 0.0168 -vn -0.0109 -0.0078 -0.9999 -vn 0.0001 -1.0000 0.0078 -usemtl none.007 -s 1 -f 1/1/1 2/2/1 3/3/1 4/4/1 -f 5/5/1 6/6/1 7/7/1 8/8/1 -f 1/9/2 4/10/2 8/8/2 5/5/2 -f 2/11/2 3/12/2 7/13/2 6/14/2 -f 1/15/3 2/16/3 6/17/3 5/18/3 -f 4/19/3 3/3/3 7/20/3 8/21/3 +mtllib jeija_wall_lever_on.mtl o nodebox1.006 -v 0.070437 -0.459607 -0.138449 -v 0.070383 -0.407163 -0.058550 -v 0.070618 -0.117856 -0.289534 -v 0.070672 -0.170301 -0.369433 -v -0.054549 -0.459593 -0.139679 -v -0.054604 -0.407150 -0.059783 -v -0.054369 -0.117843 -0.290768 -v -0.054313 -0.170287 -0.370665 -vt 0.0000 0.0000 -vt 0.0000 0.0000 -vt 0.0000 0.0000 -vt 0.0000 0.0000 -vt 0.0625 0.5625 -vt 0.1250 0.5625 -vt 0.1250 0.8750 -vt 0.0625 0.8750 -vt 0.1875 0.5625 -vt 0.2500 0.5625 -vt 0.2500 0.8750 -vt 0.1875 0.8750 -vt 0.1250 0.5625 -vt 0.1250 0.8750 -vt 0.0625 0.8750 -vt 0.0625 0.5625 -vt 0.2500 0.5625 -vt 0.2500 0.8750 -vt 0.1875 0.8750 -vt 0.1875 0.5625 -vt 0.6250 0.8750 -vt 0.6250 0.9375 -vt 0.5625 0.9375 -vt 0.5625 0.8750 -vn -0.0055 -0.8360 0.5487 -vn -1.0000 0.0002 -0.0008 -vn -0.0076 0.6239 0.7814 -vn -0.0076 0.6239 0.7815 +v 0.070437 -0.138656 0.459545 +v 0.070383 -0.058733 0.407137 +v -0.054604 -0.059966 0.407123 +v -0.054549 -0.139886 0.459530 +v 0.070618 -0.289587 0.117726 +v 0.070672 -0.369510 0.170135 +v -0.054369 -0.290821 0.117712 +v -0.054313 -0.370742 0.170120 +vt 0.000000 0.000000 +vt 0.000000 0.000000 +vt 0.000000 0.000000 +vt 0.000000 0.000000 +vt 0.062500 0.562500 +vt 0.125000 0.562500 +vt 0.125000 0.875000 +vt 0.062500 0.875000 +vt 0.187500 0.562500 +vt 0.250000 0.562500 +vt 0.250000 0.875000 +vt 0.187500 0.875000 +vt 0.125000 0.562500 +vt 0.125000 0.875000 +vt 0.062500 0.875000 +vt 0.062500 0.562500 +vt 0.250000 0.562500 +vt 0.250000 0.875000 +vt 0.187500 0.875000 +vt 0.187500 0.562500 +vt 0.625000 0.875000 +vt 0.625000 0.937500 +vt 0.562500 0.937500 +vt 0.562500 0.875000 +vn -0.0055 0.5483 0.8362 +vn -1.0000 -0.0008 -0.0002 +vn -0.0076 0.7817 -0.6236 +vn -0.0055 0.5484 0.8362 usemtl none.000_NONE.002 s 1 -f 9/22/4 10/23/4 14/24/4 13/25/4 +f 1/1/1 2/2/1 3/3/1 4/4/1 usemtl none.006 -f 9/26/5 10/27/5 11/28/5 12/29/5 -f 13/30/5 14/31/5 15/32/5 16/33/5 -f 9/34/6 12/35/6 16/36/6 13/37/6 -f 10/38/7 11/39/7 15/40/7 14/41/7 -f 12/42/4 11/43/4 15/44/4 16/45/4 +f 1/5/2 2/6/2 5/7/2 6/8/2 +f 4/9/2 3/10/2 7/11/2 8/12/2 +f 1/13/3 6/14/3 8/15/3 4/16/3 +f 2/17/3 5/18/3 7/19/3 3/20/3 +f 6/21/4 5/22/4 7/23/4 8/24/4 +o nodebox1.007 +v -0.170183 0.248540 0.492297 +v -0.161792 -0.249880 0.495967 +v -0.161781 -0.250782 0.372940 +v -0.170172 0.247638 0.369270 +v 0.161753 0.244912 0.492305 +v 0.170145 -0.253508 0.495975 +v 0.170155 -0.254410 0.372949 +v 0.161764 0.244010 0.369279 +vt 0.500000 0.203100 +vt 0.000000 0.203100 +vt 0.000000 0.000000 +vt 0.500000 0.000000 +vt 0.500000 0.203100 +vt 0.000000 0.203100 +vt 0.000000 0.000000 +vt 0.500000 0.000000 +vt 0.000000 0.203100 +vt 0.000100 0.000100 +vt 0.500000 0.000000 +vt 0.500000 0.203100 +vt 0.000000 0.203100 +vt 0.000000 -0.000000 +vt 0.000000 0.500000 +vt 0.000000 0.000000 +vt 0.500000 -0.000000 +vt 0.500000 0.500000 +vt -0.000000 0.500000 +vt 0.500000 -0.000000 +vt 0.500000 0.500000 +vn 0.9999 0.0168 -0.0000 +vn -0.0109 -0.9999 0.0073 +vn 0.0001 0.0074 1.0000 +usemtl none.007 +s 1 +f 9/25/5 10/26/5 11/27/5 12/28/5 +f 13/29/5 14/30/5 15/31/5 16/32/5 +f 9/33/6 12/34/6 16/32/6 13/29/6 +f 10/35/6 11/36/6 15/37/6 14/38/6 +f 9/39/7 10/40/7 14/41/7 13/42/7 +f 12/43/7 11/27/7 15/44/7 16/45/7