Some fix for walllever/button receiver digging

This commit is contained in:
Jeija 2012-08-17 23:48:09 +02:00
parent fe1606eb31
commit c5bf95f79d

View File

@ -47,14 +47,14 @@ end
mesecon:register_conductor("mesecons_receiver:receiver_on", "mesecons_receiver:receiver_off", mesecon:get_rules("mesecon_receiver_all"), receiver_get_rules) mesecon:register_conductor("mesecons_receiver:receiver_on", "mesecons_receiver:receiver_off", mesecon:get_rules("mesecon_receiver_all"), receiver_get_rules)
function mesecon:receiver_get_pos_from_rcpt(pos) function mesecon:receiver_get_pos_from_rcpt(pos, param2)
node = minetest.env:get_node(pos)
local rules = mesecon:get_rules("receiver_pos") local rules = mesecon:get_rules("receiver_pos")
if node.param2 == 2 then if param2 == nil then param2 = minetest.env:get_node(pos).param2 end
if param2 == 2 then
rules = mesecon:rotate_rules_left(rules) rules = mesecon:rotate_rules_left(rules)
elseif node.param2 == 3 then elseif param2 == 3 then
rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules)) rules = mesecon:rotate_rules_right(mesecon:rotate_rules_right(rules))
elseif node.param2 == 0 then elseif param2 == 0 then
rules = mesecon:rotate_rules_right(rules) rules = mesecon:rotate_rules_right(rules)
end end
np = { np = {
@ -66,8 +66,8 @@ end
function mesecon:receiver_place(rcpt_pos) function mesecon:receiver_place(rcpt_pos)
local node = minetest.env:get_node(rcpt_pos) local node = minetest.env:get_node(rcpt_pos)
pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2) local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
nn = minetest.env:get_node(pos) local nn = minetest.env:get_node(pos)
if string.find(nn.name, "mesecons:wire_") ~= nil then if string.find(nn.name, "mesecons:wire_") ~= nil then
minetest.env:dig_node(pos) minetest.env:dig_node(pos)
@ -76,11 +76,11 @@ function mesecon:receiver_place(rcpt_pos)
end end
end end
function mesecon:receiver_remove(rcpt_pos) function mesecon:receiver_remove(rcpt_pos, dugnode)
pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos) local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
node = minetest.env:get_node(pos) local nn = minetest.env:get_node(pos)
print(nn.name)
if string.find(node.name, "mesecons_receiver:receiver_") ~=nil then if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
minetest.env:dig_node(pos) minetest.env:dig_node(pos)
minetest.env:place_node(pos, {name = "mesecons:wire_00000000_off"}) minetest.env:place_node(pos, {name = "mesecons:wire_00000000_off"})
mesecon:update_autoconnect(pos) mesecon:update_autoconnect(pos)
@ -95,7 +95,7 @@ end)
minetest.register_on_dignode(function(pos, node) minetest.register_on_dignode(function(pos, node)
if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
mesecon:receiver_remove(pos) mesecon:receiver_remove(pos, node)
end end
end) end)