Skip to content

Commit 63998fd

Browse files
committedJun 8, 2014
Localize a few variables, add "GET" command to node detector.
1 parent 99cb021 commit 63998fd

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed
 

‎mesecons_detector/init.lua

+14-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
local GET_COMMAND = "GET"
2+
13
-- Object detector
24
-- Detects players in a certain radius
35
-- The radius can be specified in mesecons/settings.lua
@@ -33,7 +35,7 @@ local object_detector_scan = function (pos)
3335
end
3436

3537
-- set player name when receiving a digiline signal on a specific channel
36-
object_detector_digiline = {
38+
local object_detector_digiline = {
3739
effector = {
3840
action = function (pos, node, channel, msg)
3941
local meta = minetest.get_meta(pos)
@@ -140,17 +142,24 @@ local node_detector_scan = function (pos)
140142
end
141143

142144
-- set player name when receiving a digiline signal on a specific channel
143-
node_detector_digiline = {
145+
local node_detector_digiline = {
144146
effector = {
145147
action = function (pos, node, channel, msg)
146148
local meta = minetest.get_meta(pos)
147149
local active_channel = meta:get_string("digiline_channel")
148150
if channel == active_channel then
149-
meta:set_string("scanname", msg)
150-
node_detector_make_formspec(pos)
151+
if msg == GET_COMMAND then
152+
local frontpos = vector.subtract(pos, minetest.facedir_to_dir(node.param2))
153+
local name = minetest.get_node(frontpos).name
154+
digiline:receptor_send(pos, digiline.rules.default, channel, name)
155+
else
156+
meta:set_string("scanname", msg)
157+
node_detector_make_formspec(pos)
158+
end
151159
end
152160
end,
153-
}
161+
},
162+
receptor = {}
154163
}
155164

156165
minetest.register_node("mesecons_detector:node_detector_off", {

0 commit comments

Comments
 (0)
Please sign in to comment.