summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Zhang <azhang9@gmail.com>2013-03-11 17:37:50 -0400
committerAnthony Zhang <azhang9@gmail.com>2013-03-11 17:37:50 -0400
commit4406654fa4c031882aaffddd6608ba011b8174c3 (patch)
treef8040938b6e5bede787989e718b5e4617a9e37cc
parentdb90c1cb4b351a533145e7c246ee3a625af63c2b (diff)
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.
-rw-r--r--mesecons_mvps/init.lua8
-rw-r--r--mesecons_pistons/init.lua4
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