summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mesecons_receiver/init.lua26
1 files changed, 13 insertions, 13 deletions
diff --git a/mesecons_receiver/init.lua b/mesecons_receiver/init.lua
index c203102..dca1e22 100644
--- a/mesecons_receiver/init.lua
+++ b/mesecons_receiver/init.lua
@@ -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)
-function mesecon:receiver_get_pos_from_rcpt(pos)
- node = minetest.env:get_node(pos)
+function mesecon:receiver_get_pos_from_rcpt(pos, param2)
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)
- elseif node.param2 == 3 then
+ elseif param2 == 3 then
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)
end
np = {
@@ -66,8 +66,8 @@ end
function mesecon:receiver_place(rcpt_pos)
local node = minetest.env:get_node(rcpt_pos)
- pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
- nn = minetest.env:get_node(pos)
+ local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, node.param2)
+ local nn = minetest.env:get_node(pos)
if string.find(nn.name, "mesecons:wire_") ~= nil then
minetest.env:dig_node(pos)
@@ -76,11 +76,11 @@ function mesecon:receiver_place(rcpt_pos)
end
end
-function mesecon:receiver_remove(rcpt_pos)
- pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos)
- node = minetest.env:get_node(pos)
-
- if string.find(node.name, "mesecons_receiver:receiver_") ~=nil then
+function mesecon:receiver_remove(rcpt_pos, dugnode)
+ local pos = mesecon:receiver_get_pos_from_rcpt(rcpt_pos, dugnode.param2)
+ local nn = minetest.env:get_node(pos)
+ print(nn.name)
+ if string.find(nn.name, "mesecons_receiver:receiver_") ~=nil then
minetest.env:dig_node(pos)
minetest.env:place_node(pos, {name = "mesecons:wire_00000000_off"})
mesecon:update_autoconnect(pos)
@@ -95,7 +95,7 @@ end)
minetest.register_on_dignode(function(pos, node)
if minetest.get_item_group(node.name, "mesecon_needs_receiver") == 1 then
- mesecon:receiver_remove(pos)
+ mesecon:receiver_remove(pos, node)
end
end)