Simpler piston push/pull method.

This commit is contained in:
Anthony Zhang 2012-11-28 23:32:24 -05:00
parent aaddd9e74d
commit 3bab7cb252

@ -173,7 +173,6 @@ function mesecon:piston_push(pos)
local checknode = minetest.env:get_node(pos) local checknode = minetest.env:get_node(pos)
--add pusher --add pusher
minetest.env:dig_node(pos) --remove the first node
if node.name == "mesecons_pistons:piston_normal" then if node.name == "mesecons_pistons:piston_normal" then
minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2}) minetest.env:add_node(pos, {name="mesecons_pistons:piston_pusher_normal", param2=node.param2})
else else
@ -191,11 +190,16 @@ function mesecon:piston_push(pos)
--move the node forward --move the node forward
local nextnode = minetest.env:get_node(pos) local nextnode = minetest.env:get_node(pos)
minetest.env:dig_node(checkpos)
minetest.env:add_node(pos, checknode) minetest.env:add_node(pos, checknode)
checknode = nextnode
end
--update nodes
for i = 1, count do
mesecon:updatenode(pos) mesecon:updatenode(pos)
nodeupdate(pos) nodeupdate(pos)
checknode = nextnode
pos.x, pos.y, pos.z = pos.x - dir.x, pos.y - dir.y, pos.z - dir.z --move to the previous node
end end
end end
@ -223,13 +227,12 @@ function mesecon:piston_pull(pos)
and minetest.registered_nodes[checknode.name].liquidtype == "none" and minetest.registered_nodes[checknode.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(checknode.name) then and not mesecon:is_mvps_stopper(checknode.name) then
minetest.env:add_node(pos, checknode) minetest.env:add_node(pos, checknode)
mesecon:updatenode(pos) minetest.env:remove_node(checkpos)
nodeupdate(pos)
minetest.env:dig_node(checkpos)
mesecon:updatenode(checkpos) mesecon:updatenode(checkpos)
nodeupdate(checkpos) nodeupdate(checkpos)
end end
end end
mesecon:updatenode(pos)
nodeupdate(pos) nodeupdate(pos)
end end