Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Don't totally force deactivation of block two below the pressure plat…
…e if connected to a receptor
  • Loading branch information
Jeija committed Feb 24, 2013
1 parent 2848df0 commit e707afe
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions mesecons_pressureplates/init.lua
Expand Up @@ -17,20 +17,23 @@ pp_on_timer = function (pos, elapsed)
if not ppspec then return end

local objs = minetest.env:get_objects_inside_radius(pos, 1)
local two_below = mesecon:addPosRule(pos, {x = 0, y = -2, z = 0})

if objs[1] == nil and node.name == ppspec.onstate then
minetest.env:add_node(pos, {name = ppspec.offstate})
mesecon:receptor_off(pos)
-- force deactivation of mesecon two blocks below (hacky)
mesecon:turnoff(mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}))
if not mesecon:connected_to_receptor(two_below) then
mesecon:turnoff(two_below)
end
else
for k, obj in pairs(objs) do
local objpos = obj:getpos()
if objpos.y > pos.y-1 and objpos.y < pos.y then
minetest.env:add_node(pos, {name=ppspec.onstate})
mesecon:receptor_on(pos)
-- force activation of mesecon two blocks below (hacky)
mesecon:turnon(mesecon:addPosRule(pos, {x = 0, y = -2, z = 0}))
mesecon:turnon(two_below)
end
end
end
Expand Down

0 comments on commit e707afe

Please sign in to comment.