|
| 1 | +local GET_COMMAND = "GET" |
| 2 | + |
1 | 3 | -- Object detector
|
2 | 4 | -- Detects players in a certain radius
|
3 | 5 | -- The radius can be specified in mesecons/settings.lua
|
@@ -33,7 +35,7 @@ local object_detector_scan = function (pos)
|
33 | 35 | end
|
34 | 36 |
|
35 | 37 | -- set player name when receiving a digiline signal on a specific channel
|
36 |
| -object_detector_digiline = { |
| 38 | +local object_detector_digiline = { |
37 | 39 | effector = {
|
38 | 40 | action = function (pos, node, channel, msg)
|
39 | 41 | local meta = minetest.get_meta(pos)
|
@@ -140,17 +142,24 @@ local node_detector_scan = function (pos)
|
140 | 142 | end
|
141 | 143 |
|
142 | 144 | -- set player name when receiving a digiline signal on a specific channel
|
143 |
| -node_detector_digiline = { |
| 145 | +local node_detector_digiline = { |
144 | 146 | effector = {
|
145 | 147 | action = function (pos, node, channel, msg)
|
146 | 148 | local meta = minetest.get_meta(pos)
|
147 | 149 | local active_channel = meta:get_string("digiline_channel")
|
148 | 150 | 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 |
151 | 159 | end
|
152 | 160 | end,
|
153 |
| - } |
| 161 | + }, |
| 162 | + receptor = {} |
154 | 163 | }
|
155 | 164 |
|
156 | 165 | minetest.register_node("mesecons_detector:node_detector_off", {
|
|
0 commit comments