Vertical mesecon plugs and sockets! Plugs will now affect sockets on a level two below or two above, as long as there is air between them.

This commit is contained in:
Anthony Zhang 2012-03-09 22:49:37 -05:00
parent 36ae0cc1a5
commit 84656e079d

View File

@ -72,6 +72,12 @@ local plug_on = function(pos, node)
local lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away local lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x+2, y=pos.y, z=pos.z}) end if lnode.name=="air" then set_node_on({x=pos.x+2, y=pos.y, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y-2, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y+2, z=pos.z}) end
local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away local lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z-2}) end if lnode.name=="air" then set_node_on({x=pos.x, y=pos.y, z=pos.z-2}) end
@ -88,6 +94,12 @@ local plug_off = function(pos, node)
lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away lnode = minetest.env:get_node({x=pos.x+1, y=pos.y, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x+2, y=pos.y, z=pos.z}) end if lnode.name=="air" then set_node_off({x=pos.x+2, y=pos.y, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y-1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y-2, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y+1, z=pos.z}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y+2, z=pos.z}) end
lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away lnode = minetest.env:get_node({x=pos.x, y=pos.y, z=pos.z-1}) --a node between this node and the one two nodes away
if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z-2}) end if lnode.name=="air" then set_node_off({x=pos.x, y=pos.y, z=pos.z-2}) end