From 4406654fa4c031882aaffddd6608ba011b8174c3 Mon Sep 17 00:00:00 2001 From: Anthony Zhang Date: Mon, 11 Mar 2013 17:37:50 -0400 Subject: 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. --- mesecons_mvps/init.lua | 8 ++++++-- mesecons_pistons/init.lua | 4 +++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/mesecons_mvps/init.lua b/mesecons_mvps/init.lua index 9c94757..6107ba3 100644 --- a/mesecons_mvps/init.lua +++ b/mesecons_mvps/init.lua @@ -57,6 +57,7 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio -- remove all nodes for _, n in ipairs(nodes) do + n.meta = minetest.env:get_meta(n.pos):to_table() minetest.env:remove_node(n.pos) end @@ -70,6 +71,7 @@ function mesecon:mvps_push(pos, dir, maximum) -- pos: pos of mvps; dir: directio for _, n in ipairs(nodes) do np = mesecon:addPosRule(n.pos, dir) minetest.env:add_node(np, n.node) + minetest.env:get_meta(np):from_table(n.meta) end 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" 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:add_node(pos, nn) + minetest.env:get_meta(pos):from_table(meta) nodeupdate(np) 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} 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) oldpos = {x=lpos2.x, y=lpos2.y, z=lpos2.z} 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) end -mesecon:register_mvps_stopper("default:chest") mesecon:register_mvps_stopper("default:chest_locked") mesecon:register_mvps_stopper("default:furnace") diff --git a/mesecons_pistons/init.lua b/mesecons_pistons/init.lua index d496b1e..4998ae6 100644 --- a/mesecons_pistons/init.lua +++ b/mesecons_pistons/init.lua @@ -8,7 +8,9 @@ piston_rules = {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}} local piston_get_rules = function (node) local rules = piston_rules -- cgit v1.2.3