Added facedir pull direction for sticky pistons

This commit is contained in:
Jeija 2012-01-28 07:11:33 +01:00
parent 1bb6074f1a
commit 764be5dd4c

View File

@ -756,15 +756,15 @@ minetest.register_node("jeija:piston_normal", {
minetest.register_craft({ minetest.register_craft({
output = '"jeija:piston_normal" 2', output = '"jeija:piston_normal" 2',
recipe = { recipe = {
{'"default:wood"', '"default:wood"', '"default:wood"'}, {"default:wood", "default:wood", "default:wood"},
{'"default:cobble"', '"default:steel_ingot"', '"default:cobble"'}, {"default:cobble", "default:steel_ingot", "default:cobble"},
{'"default:cobble"', '"jeija:mesecon_off"', '"default:cobble"'}, {"default:cobble", "jeija:mesecon_off", "default:cobble"},
} }
}) })
--registration sticky one: --registration sticky one:
minetest.register_node("jeija:piston_sticky", { minetest.register_node("jeija:piston_sticky", {
tile_images = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png", "jeija_piston_sticky_side.png", "jeija_piston_sticky_side.png", "jeija_piston_sticky_side.png"}, tile_images = {"jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_tb.png", "jeija_piston_sticky_side.png"},
material = minetest.digprop_stonelike(0.5), material = minetest.digprop_stonelike(0.5),
paramtype2="facedir", paramtype2="facedir",
}) })
@ -831,6 +831,7 @@ end
-- get pull/push direction sticky -- get pull/push direction sticky
function mesecon:sticky_piston_get_direction(pos) function mesecon:sticky_piston_get_direction(pos)
if OLD_PISTON_DIRECTION==1 then
getactivated=0 getactivated=0
local direction = {x=0, y=0, z=0} local direction = {x=0, y=0, z=0}
local lpos={x=pos.x, y=pos.y, z=pos.z} local lpos={x=pos.x, y=pos.y, z=pos.z}
@ -863,6 +864,21 @@ function mesecon:sticky_piston_get_direction(pos)
getactivated=getactivated+mesecon:is_power_off(pos, rules[l].x, rules[l].y, rules[l].z) getactivated=getactivated+mesecon:is_power_off(pos, rules[l].x, rules[l].y, rules[l].z)
end end
if getactivated>0 then direction.x=1 return direction end if getactivated>0 then direction.x=1 return direction end
else
local node=minetest.env:get_node(pos)
if node.param2==3 then
return {x=1, y=0, z=0}
end
if node.param2==2 then
return {x=0, y=0, z=1}
end
if node.param2==1 then
return {x=-1, y=0, z=0}
end
if node.param2==0 then
return {x=0, y=0, z=-1}
end
end
return direction return direction
end end