Support metadata in piston pushing (so that microcontrollers and such can be pushed), support pushing chests (not locked ones though), and add two missing rules for pistons (z- top and bottom, but not z- itself). This still avoids the piston pushing power source issue.

This commit is contained in:
Anthony Zhang 2013-03-11 17:37:50 -04:00
parent db90c1cb4b
commit 4406654fa4
2 changed files with 9 additions and 3 deletions

View File

@ -57,6 +57,7 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
-- remove all nodes -- remove all nodes
for _, n in ipairs(nodes) do for _, n in ipairs(nodes) do
n.meta = minetest.env:get_meta(n.pos):to_table()
minetest.env:remove_node(n.pos) minetest.env:remove_node(n.pos)
end end
@ -70,6 +71,7 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio
for _, n in ipairs(nodes) do for _, n in ipairs(nodes) do
np = mesecon:addPosRule(n.pos, dir) np = mesecon:addPosRule(n.pos, dir)
minetest.env:add_node(np, n.node) minetest.env:add_node(np, n.node)
minetest.env:get_meta(np):from_table(n.meta)
end end
for i in ipairs(nodes) do for i in ipairs(nodes) do
@ -85,8 +87,10 @@ function mesecon:mvps_pull_single(pos, dir) -- pos: pos of mvps; direction: dire
if minetest.registered_nodes[nn.name].liquidtype == "none" if minetest.registered_nodes[nn.name].liquidtype == "none"
and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then and not mesecon:is_mvps_stopper(nn, {x = -dir.x, y = -dir.y, z = -dir.z}, {{pos = np, node = nn}}, 1) then
local meta = minetest.env:get_meta(np):to_table()
minetest.env:remove_node(np) minetest.env:remove_node(np)
minetest.env:add_node(pos, nn) minetest.env:add_node(pos, nn)
minetest.env:get_meta(pos):from_table(meta)
nodeupdate(np) nodeupdate(np)
nodeupdate(pos) nodeupdate(pos)
@ -107,7 +111,8 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z} local oldpos = {x=lpos2.x+direction.x, y=lpos2.y+direction.y, z=lpos2.z+direction.z}
repeat repeat
minetest.env:add_node(oldpos, {name=minetest.env:get_node(lpos2).name}) lnode2 = minetest.env:get_node(lpos2)
minetest.env:add_node(oldpos, {name=lnode2.name})
nodeupdate(oldpos) nodeupdate(oldpos)
oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z} oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z}
lpos2.x = lpos2.x-direction.x lpos2.x = lpos2.x-direction.x
@ -118,6 +123,5 @@ function mesecon:mvps_pull_all(pos, direction) -- pos: pos of mvps; direction: d
minetest.env:remove_node(oldpos) minetest.env:remove_node(oldpos)
end end
mesecon:register_mvps_stopper("default:chest")
mesecon:register_mvps_stopper("default:chest_locked") mesecon:register_mvps_stopper("default:chest_locked")
mesecon:register_mvps_stopper("default:furnace") mesecon:register_mvps_stopper("default:furnace")

View File

@ -8,7 +8,9 @@ piston_rules =
{x=-1, y=1, z=0}, {x=-1, y=1, z=0},
{x=-1, y=-1, z=0}, {x=-1, y=-1, z=0},
{x=0, y=1, z=1}, {x=0, y=1, z=1},
{x=0, y=-1, z=1}} {x=0, y=-1, z=1},
{x=0, y=1, z=-1},
{x=0, y=-1, z=-1}}
local piston_get_rules = function (node) local piston_get_rules = function (node)
local rules = piston_rules local rules = piston_rules